data_sector_size parameterization is proceeding apace
[dbsrgits/DBM-Deep.git] / t / 38_transaction_add_item.todo
1 use strict;
2 use Test::More tests => 9;
3 use Test::Deep;
4 use t::common qw( new_fh );
5
6 use_ok( 'DBM::Deep' );
7
8 my ($fh, $filename) = new_fh();
9 my $db = DBM::Deep->new(
10     file => $filename,
11     locking => 1,
12     autoflush => 1,
13     num_txns  => 16,
14 );
15
16 {
17     my $obj = bless {
18         foo => 5,
19     }, 'Foo';
20
21     cmp_ok( $obj->{foo}, '==', 5, "FOO is 5 in the object" );
22     ok( !exists $obj->{bar}, "BAR doesn't exist in the object" );
23
24     $db->begin_work;
25
26         $db->{foo} = $obj;
27         $db->{foo}{bar} = 1;
28
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" );
31
32     $db->rollback;
33
34 TODO: {
35     local $TODO = "Adding items in transactions will be fixed soon";
36     local $^W;
37     cmp_ok( $obj->{foo}, '==', 5 );
38 }
39     ok( !exists $obj->{bar}, "bar doesn't exist" );
40 TODO: {
41     local $TODO = "Adding items in transactions will be fixed soon";
42     ok( !tied(%$obj), "And it's not tied" );
43 }
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
59         $db->{foo} = $obj;
60         $db->{foo}{bar} = 1;
61
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" );
64
65     $db->commit;
66
67     cmp_ok( $obj->{foo}, '==', 5 );
68     ok( !exists $obj->{bar} );
69 }