Commit | Line | Data |
ffed8b01 |
1 | ## |
2 | # DBM::Deep Test |
3 | ## |
4 | use strict; |
5 | use Test::More; |
6 | use Test::Exception; |
7 | |
ebbe4093 |
8 | plan tests => 7; |
ffed8b01 |
9 | |
10 | use_ok( 'DBM::Deep' ); |
11 | |
12 | unlink "t/test.db"; |
075910ed |
13 | my $db = DBM::Deep->new( "t/test.db" ); |
ffed8b01 |
14 | if ($db->error()) { |
15 | die "ERROR: " . $db->error(); |
16 | } |
17 | |
18 | $db->{key1} = "value1"; |
19 | is( $db->{key1}, "value1", "Value set correctly" ); |
20 | |
21 | # Testing to verify that the close() will occur if open is called on an open DB. |
14a3acb6 |
22 | $db->_open; |
ffed8b01 |
23 | |
24 | is( $db->{key1}, "value1", "Value still set after re-open" ); |
25 | |
26 | throws_ok { |
27 | my $db = DBM::Deep->new( 't' ); |
28 | } qr/^DBM::Deep: Cannot open file: t: /, "Can't open a file we aren't allowed to touch"; |
29 | |
30 | throws_ok { |
31 | my $db = DBM::Deep->new( __FILE__ ); |
32 | } qr/^DBM::Deep: Signature not found -- file is not a Deep DB/, "Only DBM::Deep DB files will be opened"; |
ebbe4093 |
33 | |
34 | TODO: { |
35 | todo_skip "lock() doesn't check to see if the file is open", 1; |
36 | my $db = DBM::Deep->new( |
37 | file => 't/test.db', |
38 | locking => 1, |
39 | ); |
40 | $db->_close; |
41 | ok( !$db->lock ); |
42 | } |
43 | |
44 | TODO: { |
45 | todo_skip "unlock() doesn't check to see if the file is open", 1; |
46 | my $db = DBM::Deep->new( |
47 | file => 't/test.db', |
48 | locking => 1, |
49 | ); |
50 | $db->lock; |
51 | $db->_close; |
52 | ok( !$db->unlock ); |
53 | } |