use v5.12; use warnings; use Test::More tests => 7; use Test::Differences; use Test::Exception; require './tags.pl'; require './fa-mp3cd'; my @Rising = ( { title => ['Tarot Woman'] }, { title => ['Run With the Wolf'] }, { title => ['Starstruck'] }, ); for (my $i = 0; $i < @Rising; $i++) { my $n = $i + 1; $Rising[$i] = { dir => './Rising', flac => "$n.flac", filename => "$n.mp3", tracknumber => $n, artist => 'Rainbow', album => 'Rising', date => '1976-05-17', %{$Rising[$i]}, }; } eq_or_diff \@Rising, [epg::flac::archive::mp3::cd::check_directory('.', [], @Rising)], 'empty work directory'; eq_or_diff \@Rising, [epg::flac::archive::mp3::cd::check_directory( '.', ['./Rising/1.mp3'], @Rising)], 'track 1 exists - plan to write 1-3'; eq_or_diff [@Rising[1,2]], [epg::flac::archive::mp3::cd::check_directory( '.', [ './Rising/1.mp3', './Rising/2.mp3', ], @Rising)], 'track 1,2 exist - plan to write 2,3'; eq_or_diff [$Rising[2]], [epg::flac::archive::mp3::cd::check_directory( '.', [ './Rising/1.mp3', './Rising/2.mp3', './Rising/3.mp3', ], @Rising)], 'track 1-3 exist - plan to write 3'; throws_ok { epg::flac::archive::mp3::cd::check_directory( '.', ['./unexpected1'], @Rising) } qr(unexpected files in .: ./unexpected1), '1 unexpected file'; throws_ok { epg::flac::archive::mp3::cd::check_directory( '.', ['./unexpected1', './unexpected2'], @Rising) } qr(unexpected files in .: ./unexpected1 ./unexpected2), '2 unexpected files'; throws_ok { epg::flac::archive::mp3::cd::check_directory( '.', [ './unexpected', './Rising/1.mp3', './Rising/unexpected', './Rising/2.mp3', './l/o/l', ], @Rising) } qr(unexpected files in .: ./Rising/unexpected ./l/o/l ./unexpected), '3 unexpected files, 2 expected';