X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F81transactions.t;h=c1300de1a8e54e04eea06c73ac50d9b2d5982547;hb=d0f52dd4982eca28140a950367a203b9b466c3d2;hp=1028e7fbc36c1e6fcdfca5542c680f9793dc90d5;hpb=771298cf23765eb1651a11b47650fdf387c29d45;p=dbsrgits%2FDBIx-Class.git diff --git a/t/81transactions.t b/t/81transactions.t index 1028e7f..c1300de 100644 --- a/t/81transactions.t +++ b/t/81transactions.t @@ -329,23 +329,49 @@ $schema->storage->disconnect; }, qr/Deliberate exception.+Rollback failed/s); } -# make sure it warns and dies on failed rollbacks -TODO: { +# make sure it warns *big* on failed rollbacks +{ my $schema = DBICTest->init_schema(); - local $TODO = "Can't die in DESTROY :("; - - throws_ok (sub { - warnings_exist (sub { + # something is really confusing Test::Warn here, no time to debug +=begin + 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./, + qr/\*+ ROLLBACK FAILED\!\!\! \*+/, + ], + 'proper warnings generated on out-of-scope+rollback failure' + ); +=cut + + my @want = ( 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' ); + qr/\*+ ROLLBACK FAILED\!\!\! \*+/, + ); + + my @w; + local $SIG{__WARN__} = sub { + if (grep {$_[0] =~ $_} (@want)) { + push @w, $_[0]; + } + else { + warn $_[0]; + } + }; + { + my $guard = $schema->txn_scope_guard; + $schema->resultset ('Artist')->create ({ name => 'bohhoo'}); + + $schema->storage->disconnect; # this should freak out the guard rollback + } + + is (@w, 2, 'Both expected warnings found'); } done_testing;