From: Marius Gavrilescu Date: Sat, 1 Aug 2015 21:38:44 +0000 (+0300) Subject: Improve tests X-Git-Tag: 1.000~6 X-Git-Url: http://git.ieval.ro/?p=app-musicexpo.git;a=commitdiff_plain;h=a535e8790ef7f825c6049e16dff723d9e9b54634 Improve tests --- diff --git a/MANIFEST b/MANIFEST index 5672068..96e9c07 100644 --- 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 index e8695dc..0000000 Binary files a/empty.aac and /dev/null differ diff --git a/empty.mp3 b/empty.mp3 deleted file mode 100644 index ffa3f81..0000000 Binary files a/empty.mp3 and /dev/null differ diff --git a/empty3.mp3 b/empty3.mp3 new file mode 100644 index 0000000..ffa3f81 Binary files /dev/null and b/empty3.mp3 differ diff --git a/empty4.aac b/empty4.aac new file mode 100644 index 0000000..e8695dc Binary files /dev/null and b/empty4.aac differ diff --git a/lib/App/MusicExpo.pm b/lib/App/MusicExpo.pm index 1945687..3fccfbb 100644 --- a/lib/App/MusicExpo.pm +++ b/lib/App/MusicExpo.pm @@ -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}}; diff --git a/t/App-MusicExpo.t b/t/App-MusicExpo.t index 6102d11..fb43504 100644 --- a/t/App-MusicExpo.t +++ b/t/App-MusicExpo.t @@ -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'; diff --git a/t/musicexpo-cache.t b/t/musicexpo-cache.t index 0915c99..81016c5 100644 --- a/t/musicexpo-cache.t +++ b/t/musicexpo-cache.t @@ -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 ); } BEGIN { use_ok('App::MusicExpo'); } @@ -35,9 +33,10 @@ is $out, <<'OUT', 'output is correct'; TitleArtistAlbumGenreTrackYearType -CelluleSilenceL'autre endroitElectro01/092005FLAC MP3 +CelluleSilenceL'autre endroitElectro01/092005FLAC Vorbis +CelluleSilenceL'autre endroitElectro01/092005MP3 +CelluleSilenceL'autre endroitElectro1/92005AAC OUT ok -e $file, 'cache exists'; -tie my %db, DB_File => $file;