forked from ledgersmb/LedgerSMB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path15-loadorder.t
78 lines (48 loc) · 1.83 KB
/
15-loadorder.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!perl
=head1 UNIT TESTS FOR
LedgerSMB::Database::Loadorder
=cut
use Test2::V0;
use Data::Dumper;
use LedgerSMB::Database::Loadorder;
=head1 TEST PLAN
data is in t/data/loadorder
=head2 parse tests
=over
=item get a loadorder object
=item scripts returns correct number
=item scripts all have correct paths
=item scripts all have correct properties
=back
=cut
my $loadorder = LedgerSMB::Database::Loadorder->new('t/data/loadorder/LOADORDER');
ok($loadorder, 'got a loadorder');
ok(ref $loadorder, 'loadorder is a reference');
is(scalar $loadorder->scripts, 6, '6 scripts detected');
like($_->path, qr#t/data/loadorder/test\d.sql#, 'Script path correct')
for $loadorder->scripts;
my @notrans = (1, 3, 4);
my @scripts = $loadorder->scripts;
for my $loop (0 .. 5) {
if (grep { $_ == $loop } @notrans) {
ok($scripts[$loop]->{properties}->{no_transactions}, 'no transactions set');
} else {
ok(!$scripts[$loop]->{properties}->{no_transactions}, 'no transactions not set');
}
}
$loadorder =
LedgerSMB::Database::Loadorder->new('t/data/loadorder/LOADORDER',
upto_tag => 'ignore-from-here');
@scripts = map { my $s = $_->path; $s =~ s|t/data/loadorder/||;
$s; } $loadorder->scripts;
is(\@scripts, ['test1.sql', 'test2.sql', 'test1.sql'],
'3 scripts before "ignore-from-here" tag');
$loadorder =
LedgerSMB::Database::Loadorder->new('t/data/loadorder/LOADORDER',
upto_tag => 'ignore-me');
is(scalar $loadorder->scripts, 3, '3 scripts before "ignore-from-here" tag');
$loadorder =
LedgerSMB::Database::Loadorder->new('t/data/loadorder/LOADORDER',
upto_tag => 'ignore-me-too');
is(scalar $loadorder->scripts, 3, '3 scripts before "ignore-from-here" tag');
done_testing;