]>
Commit | Line | Data |
---|---|---|
8c158a92 | 1 | #!/usr/bin/perl -w |
23867054 MG |
2 | use v5.14; |
3 | use warnings; | |
4 | ||
5 | use Test::More tests => 3; | |
6 | ||
7 | use File::Temp qw/tempfile/; | |
23867054 MG |
8 | |
9 | my $file; | |
10 | ||
11 | BEGIN { | |
12 | $file = (tempfile UNLINK => 1)[1]; | |
a535e879 | 13 | @ARGV = (-cache => $file, sort <empty*>); |
23867054 MG |
14 | } |
15 | BEGIN { use_ok('App::MusicExpo'); } | |
16 | ||
17 | close STDOUT; | |
18 | my $out; | |
19 | open STDOUT, '>', \$out; | |
20 | ||
f7964165 MG |
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'}; | |
4a88f331 | 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'}; |
f7964165 | 37 | |
4ffde4cd | 38 | my $contents = join '', map { "\n$_" } @lines; |
f7964165 | 39 | |
23867054 MG |
40 | App::MusicExpo->run; |
41 | ||
f7964165 | 42 | is $out, <<"OUT", 'output is correct'; |
23867054 MG |
43 | <!DOCTYPE html> |
44 | <title>Music</title> | |
45 | <meta charset="utf-8"> | |
6b125df7 | 46 | <link rel="stylesheet" href="musicexpo.css"> |
1fc49a0c MG |
47 | <script async defer type="application/javascript" src="player.js"></script> |
48 | ||
49 | <div id="player"></div> | |
23867054 MG |
50 | |
51 | <table border> | |
52 | <thead> | |
53 | <tr><th>Title<th>Artist<th>Album<th>Genre<th>Track<th>Year<th>Type | |
f7964165 | 54 | <tbody>$contents |
23867054 MG |
55 | </table> |
56 | OUT | |
57 | ||
58 | ok -e $file, 'cache exists'; |