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