Improve tests
authorMarius Gavrilescu <marius@ieval.ro>
Sat, 1 Aug 2015 21:38:44 +0000 (00:38 +0300)
committerMarius Gavrilescu <marius@ieval.ro>
Sat, 1 Aug 2015 21:38:44 +0000 (00:38 +0300)
MANIFEST
empty.aac [deleted file]
empty.mp3 [deleted file]
empty3.mp3 [new file with mode: 0644]
empty4.aac [new file with mode: 0644]
lib/App/MusicExpo.pm
t/App-MusicExpo.t
t/musicexpo-cache.t

index 56720688491ff1623114f514fdd642eff7bcebc9..96e9c07b46cbbf774d0ad9d1ffe75c8627a9c71a 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -8,8 +8,8 @@ t/musicexpo.t
 lib/App/MusicExpo.pm
 musicexpo
 musicexpo.css
-empty.aac
-empty.mp3
 empty.flac
 empty.ogg
+empty3.mp3
+empty4.aac
 player.js
diff --git a/empty.aac b/empty.aac
deleted file mode 100644 (file)
index e8695dc..0000000
Binary files a/empty.aac and /dev/null differ
diff --git a/empty.mp3 b/empty.mp3
deleted file mode 100644 (file)
index ffa3f81..0000000
Binary files a/empty.mp3 and /dev/null differ
diff --git a/empty3.mp3 b/empty3.mp3
new file mode 100644 (file)
index 0000000..ffa3f81
Binary files /dev/null and b/empty3.mp3 differ
diff --git a/empty4.aac b/empty4.aac
new file mode 100644 (file)
index 0000000..e8695dc
Binary files /dev/null and b/empty4.aac differ
index 19456874f615d5be8d898a9c88353362d2fdce6f..3fccfbb333b36f430eb9d94e6f0d6dfa127f3d57 100644 (file)
@@ -18,6 +18,7 @@ use File::Basename qw/fileparse/;
 use Fcntl qw/O_RDWR O_CREAT/;
 use Getopt::Long;
 use Storable qw/thaw freeze/;
+use sort 'stable';
 
 ##################################################
 
@@ -147,8 +148,8 @@ sub run {
        );
 
        my @files;
-       for (values %files) {
-               my @versions = @$_;
+       for (sort keys %files) {
+               my @versions = @{$files{$_}};
                my %entry = (%{$versions[0]}, formats => []);
                for my $ver (@versions) {
                        push @{$entry{formats}}, {format => $ver->{format}, file => $ver->{file}};
index 6102d11683d925aeda88dc2a0270ac8ca1de34c2..fb4350413d84bce2c8b124468cd841c47dc05643 100644 (file)
@@ -9,9 +9,9 @@ use Storable qw/thaw/;
 BEGIN { use_ok('App::MusicExpo'); }
 
 my $flacinfo = thaw App::MusicExpo::flacinfo 'empty.flac';
-my $mp3info = thaw App::MusicExpo::mp3info 'empty.mp3';
+my $mp3info = thaw App::MusicExpo::mp3info 'empty3.mp3';
 my $vorbisinfo = thaw App::MusicExpo::vorbisinfo 'empty.ogg';
-my $mp4info = thaw App::MusicExpo::mp4info 'empty.aac';
+my $mp4info = thaw App::MusicExpo::mp4info 'empty4.aac';
 
 is $flacinfo->{format}, 'FLAC', 'flacinfo format';
 is $flacinfo->{title}, 'Cellule', 'flacinfo title';
@@ -31,7 +31,7 @@ is $mp3info->{album}, 'L\'autre endroit', 'mp3info album';
 is $mp3info->{tracknumber}, '01', 'mp3info tracknumber';
 is $mp3info->{tracktotal}, '09', 'mp3info tracktotal';
 is $mp3info->{genre}, 'Electro', 'mp3info genre';
-is $mp3info->{file}, 'empty.mp3', 'mp3info path';
+is $mp3info->{file}, 'empty3.mp3', 'mp3info path';
 
 is $vorbisinfo->{format}, 'Vorbis', 'vorbisinfo format';
 is $vorbisinfo->{title}, 'Cellule', 'vorbisinfo title';
@@ -51,4 +51,4 @@ is $mp4info->{album}, 'L\'autre endroit', 'mp4info album';
 is $mp4info->{tracknumber}, '1', 'mp4info tracknumber';
 is $mp4info->{tracktotal}, '9', 'mp4info tracktotal';
 is $mp4info->{genre}, 'Electro', 'mp4info genre';
-is $mp4info->{file}, 'empty.aac', 'mp4info path';
+is $mp4info->{file}, 'empty4.aac', 'mp4info path';
index 0915c999544d59bdfab3ce06b426f40f2111daa1..81016c54d7d4f621bc1b4ac8300271e94c265760 100644 (file)
@@ -5,14 +5,12 @@ use warnings;
 use Test::More tests => 3;
 
 use File::Temp qw/tempfile/;
-use DB_File;
-use Storable qw/thaw/;
 
 my $file;
 
 BEGIN {
   $file = (tempfile UNLINK => 1)[1];
-  @ARGV = (-cache => $file, 'empty.flac', 'empty.mp3');
+  @ARGV = (-cache => $file, sort <empty*>);
 }
 BEGIN { use_ok('App::MusicExpo'); }
 
@@ -35,9 +33,10 @@ is $out, <<'OUT', 'output is correct';
 <thead>
 <tr><th>Title<th>Artist<th>Album<th>Genre<th>Track<th>Year<th>Type
 <tbody>
-<tr><td class="title"><a href="#silence-cellule" data-hash="#silence-cellule">Cellule</a><td class="artist">Silence<td class="album">L&#39;autre endroit<td class="genre">Electro<td class="track">01/09<td class="year">2005<td class="formats"><a href="/music/empty.flac">FLAC</a> <a href="/music/empty.mp3">MP3</a> 
+<tr><td class="title"><a href="#silence-cellule" data-hash="#silence-cellule">Cellule</a><td class="artist">Silence<td class="album">L&#39;autre endroit<td class="genre">Electro<td class="track">01/09<td class="year">2005<td class="formats"><a href="/music/empty.flac">FLAC</a> <a href="/music/empty.ogg">Vorbis</a> 
+<tr><td class="title"><a href="#silence-cellule" data-hash="#silence-cellule">Cellule</a><td class="artist">Silence<td class="album">L&#39;autre endroit<td class="genre">Electro<td class="track">01/09<td class="year">2005<td class="formats"><a href="/music/empty3.mp3">MP3</a> 
+<tr><td class="title"><a href="#silence-cellule" data-hash="#silence-cellule">Cellule</a><td class="artist">Silence<td class="album">L&#39;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> 
 </table>
 OUT
 
 ok -e $file, 'cache exists';
-tie my %db, DB_File => $file;
This page took 0.020053 seconds and 4 git commands to generate.