Switch the main dev branch back to 'master'
[dbsrgits/DBIx-Class.git] / t / ordered / unordered_movement.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Test::Exception;
6 use lib qw(t/lib);
7 use DBICTest;
8
9 my $schema = DBICTest->init_schema();
10
11 my $cd = $schema->resultset('CD')->next;
12 $cd->tracks->delete;
13
14 $schema->resultset('CD')->related_resultset('tracks')->delete;
15
16 is $cd->tracks->count, 0, 'No tracks';
17
18 $cd->create_related('tracks', { title => "t_$_", position => $_ })
19   for (4,2,3,1,5);
20
21 is $cd->tracks->count, 5, 'Created 5 tracks';
22
23 # a txn should force the implicit pos reload, regardless of order
24 $schema->txn_do(sub {
25   $cd->tracks->delete_all
26 });
27
28 is $cd->tracks->count, 0, 'Successfully deleted everything';
29
30 done_testing;