Consolidate handling of "is this a literal" and "is this a value"
[dbsrgits/DBIx-Class.git] / t / 100populate.t
index b6ea7d9..27eb3ef 100644 (file)
@@ -6,6 +6,7 @@ use Test::Exception;
 use Test::Warn;
 use lib qw(t/lib);
 use DBICTest;
+use DBIx::Class::_Util 'sigwarn_silencer';
 use Path::Class::File ();
 use Math::BigInt;
 use List::Util qw/shuffle/;
@@ -195,7 +196,7 @@ is($link7->title, 'gtitle', 'Link 7 title');
   # test mixed binds with literal sql/bind
 
   $rs->populate([ map { +{
-    url => \[ '? || ?', [ {} => 'cpan.org_' ], [ undef, $_ ] ],
+    url => \[ '? || ?', [ {} => 'cpan.org_' ], $_ ],
     title => "The 'best of' cpan",
   } } (1 .. 5) ]);
 
@@ -209,6 +210,11 @@ is($link7->title, 'gtitle', 'Link 7 title');
 my $rs = $schema->resultset('Artist');
 $rs->delete;
 throws_ok {
+    # this warning is correct, but we are not testing it here
+    # what we are after is the correct exception when an int
+    # fails to coerce into a sqlite rownum
+    local $SIG{__WARN__} = sigwarn_silencer( qr/datatype mismatch.+ foo as integer/ );
+
     $rs->populate([
         {
             artistid => 1,
@@ -223,7 +229,7 @@ throws_ok {
             name => 'foo3',
         },
     ]);
-} qr/\Qexecute_for_fetch() aborted with 'datatype mismatch\E\b/, 'bad slice';
+} qr/\Qexecute_for_fetch() aborted with 'datatype mismatch\E\b/, 'bad slice fails PK insert';
 
 is($rs->count, 0, 'populate is atomic');
 
@@ -312,6 +318,8 @@ lives_ok {
 
 # test all kinds of population with stringified objects
 warnings_like {
+  local $ENV{DBIC_RT79576_NOWARN};
+
   my $rs = $schema->resultset('Artist')->search({}, { columns => [qw(name rank)], order_by => 'artistid' });
 
   # the stringification has nothing to do with the artist name
@@ -408,7 +416,7 @@ warnings_like {
   )
     ? ()
     # one unique for populate() and create() each
-    : (qr/\QPOSSIBLE *PAST* DATA CORRUPTION detected \E.+\QTrigger condition encountered at @{[ __FILE__ ]} line\E \d/) x 2
+    : (qr/\QPOSSIBLE *PAST* DATA CORRUPTION detected \E.+\QTrigger condition encountered at @{[ __FILE__ ]} line\E \d/) x 3
 ], 'Data integrity warnings as planned';
 
 lives_ok {