Phantom reads because transactional writes aren't deleted yet have been fixed
[dbsrgits/DBM-Deep.git] / t / 28_transactions.t
index 30e2fc9..a8a998f 100644 (file)
@@ -1,5 +1,5 @@
 use strict;
-use Test::More tests => 29;
+use Test::More tests => 31;
 use Test::Exception;
 use t::common qw( new_fh );
 
@@ -24,16 +24,16 @@ is( $db2->{x}, 'y', "Before transaction, DB2's X is Y" );
 
 $db1->begin_work;
 
-is( $db1->{x}, 'y', "DB1 transaction started, no actions - DB1's X is Y" );
-is( $db2->{x}, 'y', "DB1 transaction started, no actions - DB2's X is Y" );
+    is( $db1->{x}, 'y', "DB1 transaction started, no actions - DB1's X is Y" );
+    is( $db2->{x}, 'y', "DB1 transaction started, no actions - DB2's X is Y" );
 
-$db1->{x} = 'z';
-is( $db1->{x}, 'z', "Within DB1 transaction, DB1's X is Z" );
-is( $db2->{x}, 'y', "Within DB1 transaction, DB2's X is still Y" );
+    $db1->{x} = 'z';
+    is( $db1->{x}, 'z', "Within DB1 transaction, DB1's X is Z" );
+    is( $db2->{x}, 'y', "Within DB1 transaction, DB2's X is still Y" );
 
-$db2->{other_x} = 'foo';
-is( $db2->{other_x}, 'foo', "DB2 set other_x within DB1's transaction, so DB2 can see it" );
-is( $db1->{other_x}, undef, "Since other_x was added after the transaction began, DB1 doesn't see it." );
+    $db2->{other_x} = 'foo';
+    is( $db2->{other_x}, 'foo', "DB2 set other_x within DB1's transaction, so DB2 can see it" );
+    is( $db1->{other_x}, undef, "Since other_x was added after the transaction began, DB1 doesn't see it." );
 
 $db1->rollback;
 
@@ -45,9 +45,12 @@ is( $db2->{other_x}, 'foo', "After DB1 transaction is over, DB2 can still see ot
 
 $db1->begin_work;
 
-$db1->{x} = 'z';
-is( $db1->{x}, 'z', "Within DB1 transaction, DB1's X is Z" );
-is( $db2->{x}, 'y', "Within DB1 transaction, DB2's X is still Y" );
+    is( $db1->{x}, 'y', "DB1 transaction started, no actions - DB1's X is Y" );
+    is( $db2->{x}, 'y', "DB1 transaction started, no actions - DB2's X is Y" );
+
+    $db1->{x} = 'z';
+    is( $db1->{x}, 'z', "Within DB1 transaction, DB1's X is Z" );
+    is( $db2->{x}, 'y', "Within DB1 transaction, DB2's X is still Y" );
 
 $db1->commit;
 
@@ -56,13 +59,13 @@ is( $db2->{x}, 'z', "After commit, DB2's X is Z" );
 
 $db1->begin_work;
 
-delete $db2->{other_x};
-is( $db2->{other_x}, undef, "DB2 deleted other_x in DB1's transaction, so it can't see it anymore" );
-is( $db1->{other_x}, 'foo', "Since other_x was deleted after the transaction began, DB1 still sees it." );
+    delete $db2->{other_x};
+    is( $db2->{other_x}, undef, "DB2 deleted other_x in DB1's transaction, so it can't see it anymore" );
+    is( $db1->{other_x}, 'foo', "Since other_x was deleted after the transaction began, DB1 still sees it." );
 
-delete $db1->{x};
-is( $db1->{x}, undef, "DB1 deleted X in a transaction, so it can't see it anymore" );
-is( $db2->{x}, 'z', "But, DB2 can still see it" );
+    delete $db1->{x};
+    is( $db1->{x}, undef, "DB1 deleted X in a transaction, so it can't see it anymore" );
+    is( $db2->{x}, 'z', "But, DB2 can still see it" );
 
 $db1->rollback;
 
@@ -74,9 +77,9 @@ is( $db2->{x}, 'z', "DB2 can still see it" );
 
 $db1->begin_work;
 
-delete $db1->{x};
-is( $db1->{x}, undef, "DB1 deleted X in a transaction, so it can't see it anymore" );
-is( $db2->{x}, 'z', "But, DB2 can still see it" );
+    delete $db1->{x};
+    is( $db1->{x}, undef, "DB1 deleted X in a transaction, so it can't see it anymore" );
+    is( $db2->{x}, 'z', "But, DB2 can still see it" );
 
 $db1->commit;