Fix silent failures on autoinc PK without an is_auto_increment attribute
[dbsrgits/DBIx-Class.git] / t / 46where_attribute.t
index ba1c7d0..0fedbe7 100644 (file)
@@ -4,6 +4,7 @@ use strict;
 use warnings;
 
 use Test::More;
+use Test::Warn;
 
 use DBICTest;
 my $schema = DBICTest->init_schema();
@@ -22,9 +23,12 @@ is($programming_perl->id, 1, 'select from a resultset with find_or_create for ex
 
 # and inserts?
 my $see_spot;
-$see_spot = eval { $owner->books->find_or_create({ title => "See Spot Run" }) };
-if ($@) { print $@ }
-ok(!$@, 'find_or_create on resultset with attribute for non-existent entry did not throw');
+$see_spot = eval {
+  warnings_exist {
+    $owner->books->find_or_create({ title => "See Spot Run" })
+  } qr/Missing value for primary key column 'id' on BooksInLibrary - perhaps you forgot to set its 'is_auto_increment'/;
+};
+is ($@, '',  'find_or_create on resultset with attribute for non-existent entry did not throw');
 ok(defined $see_spot, 'successfully did insert on resultset with attribute for non-existent entry');
 
 my $see_spot_rs = $owner->books->search({ title => "See Spot Run" });