X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Frun%2F01core.tl;h=c1a5b4653ac70590a55a31bacbee0a25a50119c7;hb=b3e1f1f59a5a9010c6023f9fe5c231fe69352c20;hp=1901380104be7722ee6995a955159dd2583dc592;hpb=a4b350b1968e95392a234ae9e6e40186e97d7468;p=dbsrgits%2FDBIx-Class.git diff --git a/t/run/01core.tl b/t/run/01core.tl index 1901380..c1a5b46 100644 --- a/t/run/01core.tl +++ b/t/run/01core.tl @@ -1,7 +1,7 @@ sub run_tests { my $schema = shift; -plan tests => 51; +plan tests => 55; # figure out if we've got a version of sqlite that is older than 3.2.6, in # which case COUNT(DISTINCT()) doesn't work @@ -88,6 +88,24 @@ is($new_again->ID, 'DBICTest::Artist|artist|artistid=4', 'unique object id gener is($schema->resultset("Artist")->count, 4, 'count ok'); +# test find_or_new +{ + my $existing_obj = $schema->resultset('Artist')->find_or_new({ + artistid => 4, + }); + + is($existing_obj->name, 'Man With A Spoon', 'find_or_new: found existing artist'); + ok($existing_obj->in_storage, 'existing artist is in storage'); + + my $new_obj = $schema->resultset('Artist')->find_or_new({ + artistid => 5, + name => 'find_or_new', + }); + + is($new_obj->name, 'find_or_new', 'find_or_new: instantiated a new artist'); + ok(! $new_obj->in_storage, 'new artist is not in storage'); +} + my $cd = $schema->resultset("CD")->find(1); my %cols = $cd->get_columns;