Skip to content

Commit

Permalink
Test nested svp, too.
Browse files Browse the repository at this point in the history
  • Loading branch information
theory committed May 10, 2011
1 parent 0b85387 commit a535451
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion t/catch.t
Expand Up @@ -2,8 +2,9 @@

use strict;
use warnings;
use Test::More tests => 11;
use Test::More tests => 14;
#use Test::More 'no_plan';
use Test::MockModule;

my $CLASS;
BEGIN {
Expand Down Expand Up @@ -45,12 +46,36 @@ sub txn_outer {
});
}

my $driver = Test::MockModule->new("$CLASS\::Driver");

# Mock the savepoint driver methods.
$driver->mock( $_ => sub { shift } ) for qw(savepoint release rollback_to);

sub svp_inner {
shift->svp(sub {
die 'WTF!';
}, catch => sub {
die 'svp_inner said: '. $_;
});
}

sub svp_outer {
shift->svp(sub {
svp_inner( $conn );
}, catch => sub {
die 'svp_outer said: '. $_;
});
}

foreach my $mode (qw/ping no_ping fixup/) {
ok $conn->mode( $mode ), qq{Set mode to "$mode"};
local $@;
eval { run_outer($conn); };
like $@, qr{run_outer said: run_inner said: WTF!}, "$mode run should handle nesting";
eval { txn_outer($conn); };
like $@, qr{txn_outer said: txn_inner said: WTF!}, "$mode txn should handle nesting";
eval { svp_outer($conn); };
like $@, qr{svp_outer said: svp_inner said: Savepoint aborted: WTF!},
"$mode svp should handle nesting";
}

0 comments on commit a535451

Please sign in to comment.