Bring out the big-paranoia-harness - make describe_env infallible
[dbsrgits/DBIx-Class.git] / t / delete / complex.t
1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
2
3 use strict;
4 use warnings;
5
6 use Test::More;
7
8 use DBICTest;
9
10 my $schema = DBICTest->init_schema();
11 my $artist_rs = $schema->resultset ('Artist');
12
13 my $init_count = $artist_rs->count;
14 ok ($init_count, 'Some artists is database');
15
16 foreach my $delete_arg (
17   [ { 'me.name' => 'foo' }, { 'me.name' => 'bar' } ],
18   [ 'me.name' => 'foo', 'me.name' => 'bar' ],
19 ) {
20   $artist_rs->populate ([
21     {
22       name => 'foo',
23     },
24     {
25       name => 'bar',
26     }
27   ]);
28
29   is ($artist_rs->count, $init_count + 2, '2 Artists created');
30
31   $artist_rs->search ({
32    -and => [
33     { 'me.artistid' => { '!=', undef } },
34     $delete_arg,
35    ],
36   })->delete;
37
38   is ($artist_rs->count, $init_count, 'Correct amount of artists deleted');
39 }
40
41 done_testing;
42