[Bast-commits] r8425 - DBIx-Class/0.08/trunk/t

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Tue Jan 26 08:48:30 GMT 2010


Author: ribasushi
Date: 2010-01-26 08:48:30 +0000 (Tue, 26 Jan 2010)
New Revision: 8425

Modified:
   DBIx-Class/0.08/trunk/t/81transactions.t
Log:
Test txn_scope_guard regression

Modified: DBIx-Class/0.08/trunk/t/81transactions.t
===================================================================
--- DBIx-Class/0.08/trunk/t/81transactions.t	2010-01-26 08:33:42 UTC (rev 8424)
+++ DBIx-Class/0.08/trunk/t/81transactions.t	2010-01-26 08:48:30 UTC (rev 8425)
@@ -254,7 +254,7 @@
 
   lives_ok (sub {
     warnings_exist ( sub {
-      # The 0 arg says don't die, just let the scope guard go out of scope 
+      # The 0 arg says don't die, just let the scope guard go out of scope
       # forcing a txn_rollback to happen
       outer($schema, 0);
     }, qr/A DBIx::Class::Storage::TxnScopeGuard went out of scope without explicit commit or error. Rolling back./, 'Out of scope warning detected');
@@ -280,9 +280,9 @@
     my $artist = $artist_rs->find({ name => 'Death Cab for Cutie' });
 
     eval {
-      $artist->cds->create({ 
+      $artist->cds->create({
         title => 'Plans',
-        year => 2005, 
+        year => 2005,
         $fatal ? ( foo => 'bar' ) : ()
       });
     };
@@ -355,4 +355,40 @@
   is (@w, 2, 'Both expected warnings found');
 }
 
+# make sure AutoCommit => 0 on external handles behaves correctly with scope_guard
+{
+  my $factory = DBICTest->init_schema (AutoCommit => 0);
+  cmp_ok ($factory->resultset('CD')->count, '>', 0, 'Something to delete');
+  my $dbh = $factory->storage->dbh;
+
+  ok (!$dbh->{AutoCommit}, 'AutoCommit is off on $dbh');
+  my $schema = DBICTest::Schema->connect (sub { $dbh });
+
+
+  lives_ok ( sub {
+    my $guard = $schema->txn_scope_guard;
+    $schema->resultset('CD')->delete;
+    $guard->commit;
+  }, 'No attempt to start a transaction with scope guard');
+
+  is ($schema->resultset('CD')->count, 0, 'Deletion successful');
+}
+
+# make sure AutoCommit => 0 on external handles behaves correctly with txn_do
+{
+  my $factory = DBICTest->init_schema (AutoCommit => 0);
+  cmp_ok ($factory->resultset('CD')->count, '>', 0, 'Something to delete');
+  my $dbh = $factory->storage->dbh;
+
+  ok (!$dbh->{AutoCommit}, 'AutoCommit is off on $dbh');
+  my $schema = DBICTest::Schema->connect (sub { $dbh });
+
+
+  lives_ok ( sub {
+    $schema->txn_do (sub { $schema->resultset ('CD')->delete });
+  }, 'No attempt to start a atransaction with txn_do');
+
+  is ($schema->resultset('CD')->count, 0, 'Deletion successful');
+}
+
 done_testing;




More information about the Bast-commits mailing list