I think we are done here
[dbsrgits/DBIx-Class.git] / t / delete / complex.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use lib qw(t/lib);
6 use DBICTest;
7
8 my $schema = DBICTest->init_schema();
9 my $artist_rs = $schema->resultset ('Artist');
10
11 my $init_count = $artist_rs->count;
12 ok ($init_count, 'Some artists is database');
13
14 foreach my $delete_arg (
15   [ { 'me.name' => 'foo' }, { 'me.name' => 'bar' } ],
16   [ 'me.name' => 'foo', 'me.name' => 'bar' ],
17 ) {
18   $artist_rs->populate ([
19     {
20       name => 'foo',
21     },
22     {
23       name => 'bar',
24     }
25   ]);
26
27   is ($artist_rs->count, $init_count + 2, '2 Artists created');
28
29   $artist_rs->search ({
30    -and => [
31     { 'me.artistid' => { '!=', undef } },
32     $delete_arg,
33    ],
34   })->delete;
35
36   is ($artist_rs->count, $init_count, 'Correct amount of artists deleted');
37 }
38
39 done_testing;
40