X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F100populate.t;h=e179931281e6933ebc686671684d5486b5b5cade;hb=d096e13f26c08593a9ba497d562026beffb4f85d;hp=9e7bc8805105c218e668d50f02abf59862e7df5d;hpb=aac0bfd0de48a58cc3da1daff7614e178b4437c5;p=dbsrgits%2FDBIx-Class.git diff --git a/t/100populate.t b/t/100populate.t index 9e7bc88..e179931 100644 --- a/t/100populate.t +++ b/t/100populate.t @@ -5,6 +5,7 @@ use Test::More; use Test::Exception; use lib qw(t/lib); use DBICTest; +use Path::Class::File (); my $schema = DBICTest->init_schema(); @@ -218,4 +219,101 @@ throws_ok { ]); } qr/inconsistent/, 'literal sql must be the same in all slices'; +# the stringification has nothing to do with the artist name +# this is solely for testing consistency +my $fn = Path::Class::File->new ('somedir/somefilename.tmp'); +my $fn2 = Path::Class::File->new ('somedir/someotherfilename.tmp'); + +lives_ok { + $rs->populate([ + { + name => 'supplied before stringifying object', + }, + { + name => $fn, + } + ]); +} 'stringifying objects pass through'; + +# ... and vice-versa. + +lives_ok { + $rs->populate([ + { + name => $fn2, + }, + { + name => 'supplied after stringifying object', + }, + ]); +} 'stringifying objects pass through'; + +for ( + $fn, + $fn2, + 'supplied after stringifying object', + 'supplied before stringifying object' +) { + my $row = $rs->find ({name => $_}); + ok ($row, "Stringification test row '$_' properly inserted"); +} + +$rs->delete; + +# test stringification with ->create rather than Storage::insert_bulk as well + +lives_ok { + my @dummy = $rs->populate([ + { + name => 'supplied before stringifying object', + }, + { + name => $fn, + } + ]); +} 'stringifying objects pass through'; + +# ... and vice-versa. + +lives_ok { + my @dummy = $rs->populate([ + { + name => $fn2, + }, + { + name => 'supplied after stringifying object', + }, + ]); +} 'stringifying objects pass through'; + +for ( + $fn, + $fn2, + 'supplied after stringifying object', + 'supplied before stringifying object' +) { + my $row = $rs->find ({name => $_}); + ok ($row, "Stringification test row '$_' properly inserted"); +} + +lives_ok { + $schema->resultset('TwoKeys')->populate([{ + artist => 1, + cd => 5, + fourkeys_to_twokeys => [{ + f_foo => 1, + f_bar => 1, + f_hello => 1, + f_goodbye => 1, + autopilot => 'a', + },{ + f_foo => 2, + f_bar => 2, + f_hello => 2, + f_goodbye => 2, + autopilot => 'b', + }] + }]) +} 'multicol-PK has_many populate works'; + done_testing;