Commit | Line | Data |
c0329273 |
1 | BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } |
2 | |
375c84bb |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More; |
7 | use Test::Exception; |
c0329273 |
8 | |
375c84bb |
9 | use DBICTest; |
10 | |
11 | my $schema = DBICTest->init_schema(); |
12 | |
13 | my $cd = $schema->resultset('CD')->next; |
37b9b05b |
14 | $cd->tracks->delete; |
375c84bb |
15 | |
37b9b05b |
16 | $schema->resultset('CD')->related_resultset('tracks')->delete; |
375c84bb |
17 | |
37b9b05b |
18 | is $cd->tracks->count, 0, 'No tracks'; |
375c84bb |
19 | |
37b9b05b |
20 | $cd->create_related('tracks', { title => "t_$_", position => $_ }) |
21 | for (4,2,3,1,5); |
22 | |
23 | is $cd->tracks->count, 5, 'Created 5 tracks'; |
24 | |
25 | # a txn should force the implicit pos reload, regardless of order |
26 | $schema->txn_do(sub { |
27 | $cd->tracks->delete_all |
28 | }); |
29 | |
30 | is $cd->tracks->count, 0, 'Successfully deleted everything'; |
375c84bb |
31 | |
32 | done_testing; |