[Bast-commits] r7634 - in DBIx-Class/0.08/trunk:
lib/DBIx/Class/Storage t
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Fri Sep 11 22:59:01 GMT 2009
Author: ribasushi
Date: 2009-09-11 22:58:58 +0000 (Fri, 11 Sep 2009)
New Revision: 7634
Modified:
DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/TxnScopeGuard.pm
DBIx-Class/0.08/trunk/t/81transactions.t
Log:
scopeguard almost done
Modified: DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/TxnScopeGuard.pm
===================================================================
--- DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/TxnScopeGuard.pm 2009-09-11 22:58:21 UTC (rev 7633)
+++ DBIx-Class/0.08/trunk/lib/DBIx/Class/Storage/TxnScopeGuard.pm 2009-09-11 22:58:58 UTC (rev 7634)
@@ -25,7 +25,7 @@
my $exception = $@;
- carp 'A DBIx::Class::Storage::TxnScopeGuard went out of scope without explicit commit or error - bad'
+ carp 'A DBIx::Class::Storage::TxnScopeGuard went out of scope without explicit commit or error. Rolling back.'
unless $exception;
my $rollback_exception;
@@ -41,7 +41,8 @@
."Rollback failed: ${rollback_exception}";
}
else {
- carp "Rollback failed: ${rollback_exception}";
+ # throws an object (verified with eval{}) but DESTROY eats the exception
+ $storage->throw_exception ("Rollback failed: ${rollback_exception}");
}
}
}
Modified: DBIx-Class/0.08/trunk/t/81transactions.t
===================================================================
--- DBIx-Class/0.08/trunk/t/81transactions.t 2009-09-11 22:58:21 UTC (rev 7633)
+++ DBIx-Class/0.08/trunk/t/81transactions.t 2009-09-11 22:58:58 UTC (rev 7634)
@@ -276,7 +276,7 @@
# 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/, 'Out of scope warning detected');
+ }, qr/A DBIx::Class::Storage::TxnScopeGuard went out of scope without explicit commit or error. Rolling back./, 'Out of scope warning detected');
ok(!$artist_rs->find({name => 'Death Cab for Cutie'}), "Artist not created");
}, 'rollback successful withot exception');
@@ -329,21 +329,23 @@
}, qr/Deliberate exception.+Rollback failed/s);
}
-# make sure it simply warns on failed rollbacks
-{
+# make sure it warns and dies on failed rollbacks
+TODO: {
my $schema = DBICTest->init_schema();
- warnings_exist (sub {
- my $guard = $schema->txn_scope_guard;
- $schema->resultset ('Artist')->create ({ name => 'bohhoo'});
- $schema->storage->disconnect; # this should freak out the guard rollback
+ local $TODO = "Can't die in DESTROY :(";
- },
- [
- qr/A DBIx::Class::Storage::TxnScopeGuard went out of scope without explicit commit or error/,
- qr/Rollback failed/,
- ],
- 'out-of-scope with failed rollback properly warned');
+ throws_ok (sub {
+ warnings_exist (sub {
+ my $guard = $schema->txn_scope_guard;
+ $schema->resultset ('Artist')->create ({ name => 'bohhoo'});
+
+ $schema->storage->disconnect; # this should freak out the guard rollback
+
+ },
+ qr/A DBIx::Class::Storage::TxnScopeGuard went out of scope without explicit commit or error. Rolling back./,
+ 'out-of-scope warning');
+ }, qr/Rollback failed:/, 'rollback error thrown' );
}
done_testing;
More information about the Bast-commits
mailing list