]>
Commit | Line | Data |
---|---|---|
1 | #!/usr/bin/perl -w | |
2 | use v5.14; | |
3 | use warnings; | |
4 | ||
5 | use Test::More tests => 3; | |
6 | ||
7 | use File::Temp qw/tempfile/; | |
8 | ||
9 | my $file; | |
10 | ||
11 | BEGIN { | |
12 | $file = (tempfile UNLINK => 1)[1]; | |
13 | @ARGV = (-cache => $file, sort <empty*>); | |
14 | } | |
15 | BEGIN { use_ok('App::MusicExpo'); } | |
16 | ||
17 | close STDOUT; | |
18 | my $out; | |
19 | open STDOUT, '>', \$out; | |
20 | ||
21 | my %handled = map { $_ => 1 } App::MusicExpo::extensions_handled; | |
22 | ||
23 | my $prefix = '<tr><td class="title"><a href="#silence-cellule" data-hash="#silence-cellule">Cellule</a><td class="artist">Silence<td class="album">L'autre endroit<td class="genre">Electro<td class="track">01/09<td class="year">2005<td class="formats">'; | |
24 | ||
25 | my @lines; | |
26 | if ($handled{'.flac'} && $handled{'.ogg'}) { | |
27 | push @lines, $prefix . '<a href="/music/empty.flac">FLAC</a> <a href="/music/empty.ogg">Vorbis</a> ' | |
28 | } elsif ($handled{'.flac'}) { | |
29 | push @lines, $prefix . '<a href="/music/empty.flac">FLAC</a> ' | |
30 | } elsif ($handled{'.ogg'}) { | |
31 | push @lines, $prefix . '<a href="/music/empty.ogg">Vorbis</a> ' | |
32 | } | |
33 | ||
34 | push @lines, $prefix . '<a href="/music/empty2.opus">Opus</a> ' if $handled{'.opus'}; | |
35 | push @lines, $prefix . '<a href="/music/empty3.mp3">MP3</a> ' if $handled{'.mp3'}; | |
36 | push @lines, '<tr><td class="title"><a href="#silence-cellule" data-hash="#silence-cellule">Cellule</a><td class="artist">Silence<td class="album">L'autre endroit<td class="genre">Electro<td class="track">1/9<td class="year">2005<td class="formats"><a href="/music/empty4.aac">AAC</a> ' if $handled{'.aac'}; | |
37 | ||
38 | my $contents = join '', map { "\n$_" } @lines; | |
39 | ||
40 | App::MusicExpo->run; | |
41 | ||
42 | is $out, <<"OUT", 'output is correct'; | |
43 | <!DOCTYPE html> | |
44 | <title>Music</title> | |
45 | <meta charset="utf-8"> | |
46 | <link rel="stylesheet" href="musicexpo.css"> | |
47 | <script async defer type="application/javascript" src="player.js"></script> | |
48 | ||
49 | <div id="player"></div> | |
50 | ||
51 | <table border> | |
52 | <thead> | |
53 | <tr><th>Title<th>Artist<th>Album<th>Genre<th>Track<th>Year<th>Type | |
54 | <tbody>$contents | |
55 | </table> | |
56 | OUT | |
57 | ||
58 | ok -e $file, 'cache exists'; |