Tagged 0.981_01 (experimental auditlog)
[dbsrgits/DBM-Deep.git] / t / 23_misc.t
CommitLineData
ffed8b01 1##
2# DBM::Deep Test
3##
4use strict;
5use Test::More;
6use Test::Exception;
7
ebbe4093 8plan tests => 7;
ffed8b01 9
10use_ok( 'DBM::Deep' );
11
12unlink "t/test.db";
075910ed 13my $db = DBM::Deep->new( "t/test.db" );
ffed8b01 14if ($db->error()) {
15 die "ERROR: " . $db->error();
16}
17
18$db->{key1} = "value1";
19is( $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
24is( $db->{key1}, "value1", "Value still set after re-open" );
25
26throws_ok {
27 my $db = DBM::Deep->new( 't' );
0af414a6 28} qr/^DBM::Deep: Cannot sysopen file: t: /, "Can't open a file we aren't allowed to touch";
ffed8b01 29
30throws_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
7f441181 34{
ebbe4093 35 my $db = DBM::Deep->new(
36 file => 't/test.db',
37 locking => 1,
38 );
39 $db->_close;
40 ok( !$db->lock );
41}
42
7f441181 43{
ebbe4093 44 my $db = DBM::Deep->new(
45 file => 't/test.db',
46 locking => 1,
47 );
48 $db->lock;
49 $db->_close;
50 ok( !$db->unlock );
51}