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