5 use Test::More tests => 7;
7 use File::Temp qw( tempfile tempdir );
8 use Fcntl qw( :flock );
10 use_ok( 'DBM::Deep' );
12 my $dir = tempdir( CLEANUP => 1 );
13 my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir );
15 my $db = DBM::Deep->new( $filename );
17 $db->{key1} = "value1";
18 is( $db->{key1}, "value1", "Value set correctly" );
20 # Testing to verify that the close() will occur if open is called on an open DB.
21 #XXX WOW is this hacky ...
22 $db->_get_self->{engine}->open( $db->_get_self );
23 is( $db->{key1}, "value1", "Value still set after re-open" );
26 my $db = DBM::Deep->new( 't' );
27 } qr/^DBM::Deep: Cannot sysopen file 't': /, "Can't open a file we aren't allowed to touch";
30 my $db = DBM::Deep->new( __FILE__ );
31 } qr/^DBM::Deep: Signature not found -- file is not a Deep DB/, "Only DBM::Deep DB files will be opened";
34 my $db = DBM::Deep->new(
38 $db->_get_self->{engine}->close_fh( $db->_get_self );
43 my $db = DBM::Deep->new(
48 $db->_get_self->{engine}->close_fh( $db->_get_self );