X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F07_locking.t;h=ca335fe2344b7d3756fae4f2f8eed3e873dce02e;hb=29fc296f961943f762b5fc29b7a0b5d80d0bf6b6;hp=58ea83fbeb5a694b47da820c679b6a92bededb7d;hpb=bd7739133ff85e9bd7c1dd8fdda402c5c2ff839a;p=dbsrgits%2FDBM-Deep.git diff --git a/t/07_locking.t b/t/07_locking.t index 58ea83f..ca335fe 100644 --- a/t/07_locking.t +++ b/t/07_locking.t @@ -2,21 +2,22 @@ # DBM::Deep Test ## use strict; -use Test::More tests => 3; +use Test::More tests => 5; +use Test::Exception; +use t::common qw( new_fh ); use_ok( 'DBM::Deep' ); -## -# basic file open -## -unlink "t/test.db"; +my ($fh, $filename) = new_fh(); my $db = DBM::Deep->new( - file => "t/test.db", - locking => 1 + file => $filename, + fh => $fh, + locking => 1, ); -if ($db->error()) { - die "ERROR: " . $db->error(); -} + +lives_ok { + $db->unlock; +} "Can call unlock on an unlocked DB."; ## # basic put/get @@ -24,10 +25,13 @@ if ($db->error()) { $db->{key1} = "value1"; is( $db->{key1}, "value1", "key1 is set" ); +$db->{key2} = [ 1 .. 3 ]; +is( $db->{key2}[1], 2 ); + ## # explicit lock ## -$db->lock( DBM::Deep->LOCK_EX ); +$db->lock_exclusive; $db->{key1} = "value2"; $db->unlock(); is( $db->{key1}, "value2", "key1 is overridden" );