r14186@rob-kinyons-powerbook58: rob | 2006-06-14 11:44:48 -0400
[dbsrgits/DBM-Deep.git] / t / 36_transaction_deep.t
CommitLineData
415dcbb7 1use strict;
7a960a12 2use Test::More tests => 7;
415dcbb7 3use Test::Deep;
4use t::common qw( new_fh );
5
6use_ok( 'DBM::Deep' );
7
8my ($fh, $filename) = new_fh();
9my $db1 = DBM::Deep->new(
10 file => $filename,
11 locking => 1,
12 autoflush => 1,
13);
14
7a960a12 15my $x_outer = { a => 'b' };
867a26a0 16my $x_inner = { a => 'c' };
7a960a12 17
18$db1->{x} = $x_outer;
867a26a0 19is( $db1->{x}{a}, 'b', "BEFORE: We're looking at the right value from outer" );
7a960a12 20
415dcbb7 21$db1->begin_work;
22
7a960a12 23 $db1->{x} = $x_inner;
867a26a0 24 is( $db1->{x}{a}, 'c', "WITHIN: We're looking at the right value from inner" );
fb451ba6 25TODO: {
26 local $TODO = "Transactions not done yet";
867a26a0 27 is( $x_outer->{a}, 'c', "WITHIN: We're looking at the right value from outer" );
fb451ba6 28}
415dcbb7 29
30$db1->commit;
31
867a26a0 32is( $db1->{x}{a}, 'c', "AFTER: Commit means x_inner is still correct" );
fb451ba6 33TODO: {
34 local $TODO = "Transactions not done yet";
867a26a0 35is( $x_outer->{a}, 'c', "AFTER: outer made the move" );
36is( $x_inner->{a}, 'c', "AFTER: inner made the move" );
fb451ba6 37}