Replace many closure-based proxy methods with static qsubs
[dbsrgits/DBIx-Class.git] / t / storage / error.t
index 68bbb5a..6c9b15c 100644 (file)
@@ -6,19 +6,20 @@ use Test::Warn;
 use Test::Exception;
 
 use lib qw(t/lib);
-use_ok( 'DBICTest' );
-use_ok( 'DBICTest::Schema' );
+use DBICTest;
 
 my $schema = DBICTest->init_schema;
 
-my $e_start = quotemeta('DBIx::Class::');
-
 warnings_are ( sub {
   throws_ok (
     sub {
       $schema->resultset('CD')->create({ title => 'vacation in antarctica' })
     },
-    qr/$e_start.+constraint failed.+NULL/s
+    qr/DBI Exception.+(?x:
+      \QNOT NULL constraint failed: cd.artist\E
+        |
+      \Qcd.artist may not be NULL\E
+    )/s
   );  # as opposed to some other error
 }, [], 'No warnings besides exception' );
 
@@ -28,7 +29,7 @@ throws_ok (
   sub {
     $dbh->do ('INSERT INTO nonexistent_table VALUES (1)')
   },
-  qr/$e_start.+DBI Exception.+no such table/,
+  qr/DBI Exception.+no such table.+nonexistent_table/s,
   'DBI exceptions properly handled by dbic-installed callback'
 );
 
@@ -36,13 +37,17 @@ throws_ok (
 # destruction of everything except the $dbh should use the proper
 # exception fallback:
 
-{
+SKIP: {
+  if ( !!DBIx::Class::_ENV_::PEEPEENESS ) {
+    skip "Your perl version $] appears to leak like a sieve - skipping garbage collected \$schema test", 1;
+  }
+
   undef ($schema);
   throws_ok (
     sub {
       $dbh->do ('INSERT INTO nonexistent_table VALUES (1)')
     },
-    qr/DBI Exception.+unhandled by DBIC.+no such table/,
+    qr/DBI Exception.+unhandled by DBIC.+no such table.+nonexistent_table/s,
     'callback works after $schema is gone'
   );
 }