X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F81transactions.t;h=c1300de1a8e54e04eea06c73ac50d9b2d5982547;hb=758b5941171ad244192af1d5553d76a780394c72;hp=2c399b09e88316848548f72ce221bccf84d9103a;hpb=c6e27318d1a83b7474eaea616d47d478746609f2;p=dbsrgits%2FDBIx-Class.git diff --git a/t/81transactions.t b/t/81transactions.t index 2c399b0..c1300de 100644 --- a/t/81transactions.t +++ b/t/81transactions.t @@ -276,7 +276,7 @@ $schema->storage->disconnect; # 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,49 @@ $schema->storage->disconnect; }, qr/Deliberate exception.+Rollback failed/s); } -# make sure it simply warns on failed rollbacks +# make sure it warns *big* on failed rollbacks { 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 + # 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./, + 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 + } - }, - [ - 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'); + is (@w, 2, 'Both expected warnings found'); } done_testing;