]> diplodocus.org Git - flac-archive/blob - t/mp3cd/check-directory.t
minor tag fixes, maybe
[flac-archive] / t / mp3cd / check-directory.t
1 use v5.12;
2 use warnings;
3
4 use Test::More tests => 7;
5
6 use Test::Differences;
7 use Test::Exception;
8
9 use FindBin;
10
11 use lib "$FindBin::Bin/../..";
12
13 require 'fa-mp3cd';
14
15 my @Rising = (
16 { title => ['Tarot Woman'] },
17 { title => ['Run With the Wolf'] },
18 { title => ['Starstruck'] },
19 );
20 for (my $i = 0; $i < @Rising; $i++) {
21 my $n = $i + 1;
22 $Rising[$i] = {
23 dir => './Rising',
24 flac => "$n.flac",
25 filename => "$n.mp3",
26 tracknumber => $n,
27 artist => 'Rainbow',
28 album => 'Rising',
29 date => '1976-05-17',
30 %{$Rising[$i]},
31 };
32 }
33
34 eq_or_diff
35 \@Rising,
36 [epg::flac::archive::mp3::cd::check_directory('.', [], @Rising)],
37 'empty work directory';
38
39 eq_or_diff
40 \@Rising,
41 [epg::flac::archive::mp3::cd::check_directory(
42 '.',
43 ['./Rising/1.mp3'],
44 @Rising)],
45 'track 1 exists - plan to write 1-3';
46
47 eq_or_diff
48 [@Rising[1,2]],
49 [epg::flac::archive::mp3::cd::check_directory(
50 '.',
51 [
52 './Rising/1.mp3',
53 './Rising/2.mp3',
54 ],
55 @Rising)],
56 'track 1,2 exist - plan to write 2,3';
57
58 eq_or_diff
59 [$Rising[2]],
60 [epg::flac::archive::mp3::cd::check_directory(
61 '.',
62 [
63 './Rising/1.mp3',
64 './Rising/2.mp3',
65 './Rising/3.mp3',
66 ],
67 @Rising)],
68 'track 1-3 exist - plan to write 3';
69
70 throws_ok {
71 epg::flac::archive::mp3::cd::check_directory(
72 '.',
73 ['./unexpected1'],
74 @Rising)
75 } qr(unexpected files in .: ./unexpected1),
76 '1 unexpected file';
77
78 throws_ok {
79 epg::flac::archive::mp3::cd::check_directory(
80 '.',
81 ['./unexpected1', './unexpected2'],
82 @Rising)
83 } qr(unexpected files in .: ./unexpected1 ./unexpected2),
84 '2 unexpected files';
85
86 throws_ok {
87 epg::flac::archive::mp3::cd::check_directory(
88 '.',
89 [
90 './unexpected',
91 './Rising/1.mp3',
92 './Rising/unexpected',
93 './Rising/2.mp3',
94 './l/o/l',
95 ],
96 @Rising)
97 } qr(unexpected files in .: ./Rising/unexpected ./l/o/l ./unexpected),
98 '3 unexpected files, 2 expected';