From a535e8790ef7f825c6049e16dff723d9e9b54634 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sun, 2 Aug 2015 00:38:44 +0300 Subject: [PATCH] Improve tests --- MANIFEST | 4 ++-- empty.mp3 => empty3.mp3 | Bin empty.aac => empty4.aac | Bin lib/App/MusicExpo.pm | 5 +++-- t/App-MusicExpo.t | 8 ++++---- t/musicexpo-cache.t | 9 ++++----- 6 files changed, 13 insertions(+), 13 deletions(-) rename empty.mp3 => empty3.mp3 (100%) rename empty.aac => empty4.aac (100%) 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.mp3 b/empty3.mp3 similarity index 100% rename from empty.mp3 rename to empty3.mp3 diff --git a/empty.aac b/empty4.aac similarity index 100% rename from empty.aac rename to empty4.aac 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; -- 2.39.2