X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F81transactions.t;h=32d5f17ec9a96cb0cf3234e65caea5376142a3b5;hb=0c0339748122fa47c1e9a00351e210e080cf3593;hp=89160a8ebdd38254b6a5187eea462da3df9cd918;hpb=c52c34668d8792679f71d6c16e0bf114e8df536f;p=dbsrgits%2FDBIx-Class.git diff --git a/t/81transactions.t b/t/81transactions.t index 89160a8..32d5f17 100644 --- a/t/81transactions.t +++ b/t/81transactions.t @@ -260,7 +260,7 @@ $schema->storage->disconnect; }); $guard->commit; - } qr/No such column made_up_column .*? at .*?81transactions.t line \d+/, "Error propogated okay"; + } qr/No such column made_up_column .*? at .*?81transactions.t line \d+/s, "Error propogated okay"; ok(!$artist_rs->find({name => 'Death Cab for Cutie'}), "Artist not created"); @@ -272,7 +272,7 @@ $schema->storage->disconnect; ok(!$artist_rs->find({name => 'Death Cab for Cutie'}), "Artist not created"); - eval { + lives_ok (sub { my $w; local $SIG{__WARN__} = sub { $w = shift }; @@ -281,32 +281,27 @@ $schema->storage->disconnect; outer($schema, 0); like ($w, qr/A DBIx::Class::Storage::TxnScopeGuard went out of scope without explicit commit or an error/, 'Out of scope warning detected'); - }; - - local $TODO = "Work out how this should work"; - is($@, "Not sure what we want here, but something", "Rollback okay"); - - ok(!$artist_rs->find({name => 'Death Cab for Cutie'}), "Artist not created"); + ok(!$artist_rs->find({name => 'Death Cab for Cutie'}), "Artist not created"); + }, 'rollback successful withot exception'); sub outer { my ($schema) = @_; - + my $guard = $schema->txn_scope_guard; $schema->resultset('Artist')->create({ name => 'Death Cab for Cutie', }); inner(@_); - $guard->commit; } sub inner { my ($schema, $fatal) = @_; - my $guard = $schema->txn_scope_guard; + + my $inner_guard = $schema->txn_scope_guard; + is($schema->storage->transaction_depth, 2, "Correct transaction depth"); my $artist = $artist_rs->find({ name => 'Death Cab for Cutie' }); - is($schema->storage->transaction_depth, 2, "Correct transaction depth"); - undef $@; eval { $artist->cds->create({ title => 'Plans', @@ -320,6 +315,7 @@ $schema->storage->disconnect; die $@; } - # See what happens if we dont $guard->commit; + # inner guard should commit without consequences + $inner_guard->commit; } }