From: rkinyon Date: Thu, 27 Apr 2006 13:52:00 +0000 (+0000) Subject: Added test for commit with arrays X-Git-Tag: 0-99_02~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c0780c5e0dc3481a0eba5ce47ee0bed1ca45a829;p=dbsrgits%2FDBM-Deep.git Added test for commit with arrays --- diff --git a/t/28_transactions.t b/t/28_transactions.t index 65ea8fc..3b72a36 100644 --- a/t/28_transactions.t +++ b/t/28_transactions.t @@ -157,4 +157,3 @@ Tests to add: * Two transactions running at the same time * Doing a clear on the head while a transaction is running # More than just two keys -* Arrays (in particular, how is length handled?) diff --git a/t/34_transaction_arrays.t b/t/34_transaction_arrays.t index 5043c91..b3668c5 100644 --- a/t/34_transaction_arrays.t +++ b/t/34_transaction_arrays.t @@ -1,5 +1,5 @@ use strict; -use Test::More tests => 17; +use Test::More tests => 29; use Test::Deep; use t::common qw( new_fh ); @@ -51,3 +51,26 @@ is( $db2->[1], 'foo', "After DB1 transaction is over, DB2 can still see 1" ); cmp_ok( scalar(@$db1), '==', 2, "DB1 now has 2 elements" ); cmp_ok( scalar(@$db2), '==', 2, "DB2 still has 2 elements" ); +$db1->begin_work; + + is( $db1->[0], 'y', "DB1 transaction started, no actions - DB1's 0 is Y" ); + is( $db2->[0], 'y', "DB1 transaction started, no actions - DB2's 0 is Y" ); + + $db1->[2] = 'z'; + is( $db1->[2], 'z', "Within DB1 transaction, DB1's 2 is Z" ); + ok( !exists $db2->[2], "Within DB1 transaction, DB2 cannot see 2" ); + + cmp_ok( scalar(@$db1), '==', 3, "DB1 has 3 elements" ); + cmp_ok( scalar(@$db2), '==', 2, "DB2 has 2 elements" ); + +$db1->commit; + +is( $db1->[0], 'y', "After rollback, DB1's 0 is Y" ); +is( $db2->[0], 'y', "After rollback, DB2's 0 is Y" ); + +is( $db1->[2], 'z', "After DB1 transaction is over, DB1 can still see 2" ); +is( $db2->[2], 'z', "After DB1 transaction is over, DB2 can now see 2" ); + +cmp_ok( scalar(@$db1), '==', 3, "DB1 now has 2 elements" ); +cmp_ok( scalar(@$db2), '==', 3, "DB2 still has 2 elements" ); +