X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fmulti_create%2Fstandard.t;h=54cf04ee3181f92cd9389b528f10f9e177714482;hb=313510884be3d00975ae50f42af4f585eb29ae80;hp=6eb2b9a13b43a241cc4b1788c06be6d2ea792589;hpb=65d351219882184861384aedac6f251b6797d0d7;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/multi_create/standard.t b/t/multi_create/standard.t index 6eb2b9a..54cf04e 100644 --- a/t/multi_create/standard.t +++ b/t/multi_create/standard.t @@ -3,11 +3,10 @@ use warnings; use Test::More; use Test::Exception; +use Test::Warn; use lib qw(t/lib); use DBICTest; -plan tests => 91; - my $schema = DBICTest->init_schema(); lives_ok ( sub { @@ -112,7 +111,7 @@ lives_ok ( sub { # / # Producer lives_ok ( sub { - my $artist = $schema->resultset('Artist')->first; + my $artist = $schema->resultset('Artist')->find(1); my $cd = $schema->resultset('CD')->create ({ artist => $artist, title => 'Music to code by at night', @@ -152,7 +151,7 @@ lives_ok ( sub { is ($cd->title, 'Music to code by at night', 'Correct CD title'); is ($cd->tracks->count, 2, 'Two tracks on main CD'); - my ($t1, $t2) = $cd->tracks->all; + my ($t1, $t2) = sort { $a->id <=> $b->id } $cd->tracks->all; is ($t1->title, 'Off by one again', 'Correct 1st track name'); is ($t1->cd_single, undef, 'No single for 1st track'); is ($t2->title, 'The dereferencer', 'Correct 2nd track name'); @@ -403,8 +402,11 @@ lives_ok ( sub { $kurt_cobain->{cds} = [ $in_utero ]; + warnings_exist { + $schema->resultset('Artist')->populate([ $kurt_cobain ]); + } qr/\QFast-path populate() with supplied related objects is not possible/; + - $schema->resultset('Artist')->populate([ $kurt_cobain ]); # %) my $artist = $schema->resultset('Artist')->find({name => 'Kurt Cobain'}); is($artist->name, 'Kurt Cobain', 'Artist insertion ok'); @@ -444,7 +446,11 @@ throws_ok ( sub { #$t->cd($t->new_related('cd', { artist => undef } ) ); #$t->{_rel_in_storage} = 0; $t->insert; -}, qr/cd.artist may not be NULL/, "Exception propogated properly"); +}, qr/DBI Exception.+(?x: + \QNOT NULL constraint failed: cd.artist\E + | + \Qcd.artist may not be NULL\E +)/s, "Exception propogated properly"); lives_ok ( sub { $schema->resultset('CD')->create ({ @@ -464,4 +470,4 @@ lives_ok ( sub { is ($m2m_cd->first->producers->first->name, 'Cowboy Neal', 'Correct producer row created'); }, 'Test multi create over many_to_many'); -1; +done_testing;