X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F96multi_create.t;h=0ef9e80e601cb313c6a7ccdbb9bb896a9b334fe3;hb=2e06c56de04377bcea7898825df6db64610aeabe;hp=e07bfd95f8cf6c8b96ee70832b8bc3854f59af1e;hpb=1ceafb0cf3647c04e3e7029f7c1a2d0559f6d595;p=dbsrgits%2FDBIx-Class-Historic.git diff --git a/t/96multi_create.t b/t/96multi_create.t index e07bfd9..0ef9e80 100644 --- a/t/96multi_create.t +++ b/t/96multi_create.t @@ -6,11 +6,13 @@ use Test::Exception; use lib qw(t/lib); use DBICTest; -plan tests => 77; +sub mc_diag { diag (@_) if $ENV{DBIC_MULTICREATE_DEBUG} }; + +plan tests => 84; my $schema = DBICTest->init_schema(); -diag '* simple create + parent (the stuff $rs belongs_to)'; +mc_diag '* simple create + parent (the stuff $rs belongs_to)'; eval { my $cd = $schema->resultset('CD')->create({ artist => { @@ -26,7 +28,7 @@ eval { }; diag $@ if $@; -diag '* same as above but the child and parent have no values, except for an explicit parent pk'; +mc_diag '* same as above but the child and parent have no values, except for an explicit parent pk'; eval { my $bm_rs = $schema->resultset('Bookmark'); my $bookmark = $bm_rs->create({ @@ -48,7 +50,7 @@ eval { }; diag $@ if $@; -diag '* create over > 1 levels of has_many create (A => { has_many => { B => has_many => C } } )'; +mc_diag '* create over > 1 levels of has_many create (A => { has_many => { B => has_many => C } } )'; eval { my $artist = $schema->resultset('Artist')->first; my $cd = $artist->create_related (cds => { @@ -82,7 +84,7 @@ throws_ok ( 'create via update of multi relationships throws an exception' ); -diag '* Create m2m while originating in the linker table'; +mc_diag '* Create m2m while originating in the linker table'; eval { my $artist = $schema->resultset('Artist')->first; my $c2p = $schema->resultset('CD_to_Producer')->create ({ @@ -112,7 +114,7 @@ eval { }; diag $@ if $@; -diag (<<'DG'); +mc_diag (<<'DG'); * Create over > 1 levels of might_have with multiple has_many and multiple m2m but starting at a has_many level @@ -186,7 +188,7 @@ eval { }; diag $@ if $@; -diag (<<'DG'); +mc_diag (<<'DG'); * Same as above but starting at the might_have directly Track -> might have -> Single -> has_many -> Tracks @@ -251,7 +253,7 @@ eval { }; diag $@ if $@; -diag '* Test might_have again but with a PK == FK in the middle (obviously not specified)'; +mc_diag '* Test might_have again but with a PK == FK in the middle (obviously not specified)'; eval { my $artist = $schema->resultset('Artist')->first; my $cd = $schema->resultset('CD')->create ({ @@ -295,7 +297,7 @@ eval { }; diag $@ if $@; -diag '* Test might_have again but with just a PK and FK (neither specified) in the mid-table'; +mc_diag '* Test might_have again but with just a PK and FK (neither specified) in the mid-table'; eval { my $cd = $schema->resultset('CD')->first; my $track = $schema->resultset ('Track')->create ({ @@ -340,7 +342,7 @@ eval { }; diag $@ if $@; -diag (<<'DG'); +mc_diag (<<'DG'); * Test a multilevel might-have with a PK == FK in the might_have/has_many table CD -> might have -> Artwork @@ -391,7 +393,7 @@ eval { }; diag $@ if $@; -diag '* Nested find_or_create'; +mc_diag '* Nested find_or_create'; eval { my $newartist2 = $schema->resultset('Artist')->find_or_create({ name => 'Fred 3', @@ -406,7 +408,7 @@ eval { }; diag $@ if $@; -diag '* Multiple same level has_many create'; +mc_diag '* Multiple same level has_many create'; eval { my $artist2 = $schema->resultset('Artist')->create({ name => 'Fred 4', @@ -428,7 +430,7 @@ eval { }; diag $@ if $@; -diag '* First create_related pass'; +mc_diag '* First create_related pass'; eval { my $artist = $schema->resultset('Artist')->first; @@ -457,7 +459,7 @@ eval { }; diag $@ if $@; -diag '* second create_related with same arguments'; +mc_diag '* second create_related with same arguments'; eval { my $artist = $schema->resultset('Artist')->first; @@ -489,7 +491,7 @@ eval { }; diag $@ if $@; -diag '* create of parents of a record linker table'; +mc_diag '* create of parents of a record linker table'; eval { my $cdp = $schema->resultset('CD_to_Producer')->create({ cd => { artist => 1, title => 'foo', year => 2000 }, @@ -538,7 +540,7 @@ eval { diag $@ if $@; =cut -diag '* Create foreign key col obj including PK (See test 20 in 66relationships.t)'; +mc_diag '* Create foreign key col obj including PK (See test 20 in 66relationships.t)'; ## Create foreign key col obj including PK ## See test 20 in 66relationships.t eval { @@ -568,7 +570,7 @@ eval { }; is($@, '', 'new cd created without clash on related artist'); -diag '* Make sure exceptions from errors in created rels propogate'; +mc_diag '* Make sure exceptions from errors in created rels propogate'; eval { my $t = $schema->resultset("Track")->new({ cd => { artist => undef } }); #$t->cd($t->new_related('cd', { artist => undef } ) ); @@ -577,7 +579,7 @@ eval { }; like($@, qr/cd.artist may not be NULL/, "Exception propogated properly"); -diag '* Test multi create over many_to_many'; +mc_diag '* Test multi create over many_to_many'; eval { $schema->resultset('CD')->create ({ artist => {