Really fix SQLite savepoints unlike the shortsighted 398215b1
[dbsrgits/DBIx-Class.git] / t / storage / savepoints.t
index 5866e6d..b125d6e 100644 (file)
@@ -1,10 +1,13 @@
+BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
+
 use strict;
 use warnings;
 
 use Test::More;
 use Test::Exception;
+use DBIx::Class::Optional::Dependencies;
+use DBIx::Class::_Util qw(sigwarn_silencer scope_guard);
 
-use lib qw(t/lib);
 use DBICTest;
 
 {
@@ -34,13 +37,10 @@ for ('', keys %$env2optdep) { SKIP: {
   my $prefix;
 
   if ($prefix = $_) {
-    my ($dsn, $user, $pass) = map { $ENV{"${prefix}_$_"} } qw/DSN USER PASS/;
 
-    skip ("Skipping tests with $prefix: set \$ENV{${prefix}_DSN} _USER and _PASS", 1)
-      unless $dsn;
+    DBIx::Class::Optional::Dependencies->skip_without($env2optdep->{$prefix});
 
-    skip ("Testing with ${prefix}_DSN needs " . DBIx::Class::Optional::Dependencies->req_missing_for( $env2optdep->{$prefix} ), 1)
-      unless  DBIx::Class::Optional::Dependencies->req_ok_for($env2optdep->{$prefix});
+    my ($dsn, $user, $pass) = map { $ENV{"${prefix}_$_"} } qw/DSN USER PASS/;
 
     $schema = DBICTest::Schema->connect ($dsn,$user,$pass,{ auto_savepoint => 1 });
 
@@ -75,9 +75,9 @@ for ('', keys %$env2optdep) { SKIP: {
     { $_ => $schema->storage->$_ }
     qw(debugcb debugobj debug)
   };
-  my $sg = Scope::Guard->new(sub {
+  my $sg = scope_guard {
     $schema->storage->$_ ( $orig_states->{$_} ) for keys %$orig_states;
-  });
+  };
   $schema->storage->debugobj (my $stats = DBICTest::SVPTracerObj->new);
   $schema->storage->debug (1);
 
@@ -237,6 +237,9 @@ for ('', keys %$env2optdep) { SKIP: {
     undef,
     'rollback from inner transaction';
 
+  # make sure a fresh txn will work after above
+  $schema->storage->txn_do(sub { ok "noop" } );
+
 ### cleanupz
   $schema->storage->dbh_do(sub { $_[1]->do("DROP TABLE artist") });
 }}