Converted to using only 2 transactions by default and added the num_txns to the header
[dbsrgits/DBM-Deep.git] / t / 38_transaction_add_item.todo
CommitLineData
867a26a0 1use strict;
2use Test::More tests => 9;
3use Test::Deep;
4use t::common qw( new_fh );
5
6use_ok( 'DBM::Deep' );
7
8my ($fh, $filename) = new_fh();
9my $db = DBM::Deep->new(
10 file => $filename,
11 locking => 1,
12 autoflush => 1,
36d630c6 13 num_txns => 16,
867a26a0 14);
15
16{
17 my $obj = bless {
18 foo => 5,
19 }, 'Foo';
20
060c7e54 21 cmp_ok( $obj->{foo}, '==', 5, "FOO is 5 in the object" );
22 ok( !exists $obj->{bar}, "BAR doesn't exist in the object" );
867a26a0 23
24 $db->begin_work;
25
a67c4bbf 26 $db->{foo} = $obj;
27 $db->{foo}{bar} = 1;
867a26a0 28
a67c4bbf 29 cmp_ok( $db->{foo}{bar}, '==', 1, "The value is visible within the transaction" );
30 cmp_ok( $obj->{bar}, '==', 1, "The value is visible within the object" );
867a26a0 31
32 $db->rollback;
33
fb451ba6 34TODO: {
35 local $TODO = "Adding items in transactions will be fixed soon";
36 local $^W;
867a26a0 37 cmp_ok( $obj->{foo}, '==', 5 );
fb451ba6 38}
867a26a0 39 ok( !exists $obj->{bar}, "bar doesn't exist" );
fb451ba6 40TODO: {
41 local $TODO = "Adding items in transactions will be fixed soon";
867a26a0 42 ok( !tied(%$obj), "And it's not tied" );
fb451ba6 43}
867a26a0 44
45 ok( !exists $db->{foo}, "The transaction inside the DB works" );
46}
47
48__END__
49{
50 my $obj = bless {
51 foo => 5,
52 }, 'Foo';
53
54 cmp_ok( $obj->{foo}, '==', 5 );
55 ok( !exists $obj->{bar} );
56
57 $db->begin_work;
58
a67c4bbf 59 $db->{foo} = $obj;
60 $db->{foo}{bar} = 1;
867a26a0 61
a67c4bbf 62 cmp_ok( $db->{foo}{bar}, '==', 1, "The value is visible within the transaction" );
63 cmp_ok( $obj->{bar}, '==', 1, "The value is visible within the object" );
867a26a0 64
65 $db->commit;
66
67 cmp_ok( $obj->{foo}, '==', 5 );
68 ok( !exists $obj->{bar} );
69}