X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F96multi_create_new.t;h=9b905ebf92be08b8f719d8e22835e6d5bc2eb03e;hb=88e12210acdb453298f90cab7296e538c44bb593;hp=2afb1d17dd15c5df074489f56c2de250c7ca960e;hpb=9ffcb5b812d3a5fc8823bd40e98618fa3fabd2bc;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/96multi_create_new.t b/t/96multi_create_new.t index 2afb1d1..9b905eb 100644 --- a/t/96multi_create_new.t +++ b/t/96multi_create_new.t @@ -6,7 +6,7 @@ use Test::Exception; use lib qw(t/lib); use DBICTest; -plan tests => 6; +plan tests => 12; my $schema = DBICTest->init_schema(); @@ -35,6 +35,28 @@ my $schema = DBICTest->init_schema(); } { + my $new_artist = $schema->resultset("Artist")->new_result({ 'name' => 'Depeche Mode' }); + my $new_related_cd = $new_artist->new_related('cds', { 'title' => 'Leave Slightly Noisily', 'year' => 1982}); + eval { + $new_related_cd->insert; + }; + is ($@, '', 'CD insertion survives by finding artist'); + ok($new_artist->in_storage, 'artist inserted'); + ok($new_related_cd->in_storage, 'new_related_cd inserted'); +} + +{ + my $new_artist = $schema->resultset("Artist")->new_result({ 'name' => 'Depeche Mode 2: Insertion Boogaloo' }); + my $new_related_cd = $new_artist->new_related('cds', { 'title' => 'Leave Loudly While Singing Off Key', 'year' => 1982}); + eval { + $new_related_cd->insert; + }; + is ($@, '', 'CD insertion survives by inserting artist'); + ok($new_artist->in_storage, 'artist inserted'); + ok($new_related_cd->in_storage, 'new_related_cd inserted'); +} + +{ my $new_cd = $schema->resultset("CD")->new_result({}); my $new_related_artist = $new_cd->new_related('artist', { 'name' => 'Marillion',}); lives_ok (