X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F23_misc.t;h=c2137b8f973722cd0f27751e7b9f221d84fbf905;hb=bd01f6ece548569503416cc1af17f72d7bd532cc;hp=5a6f1794a9a9047a93c894e1e5c0a2497d30479f;hpb=70b5542878eb8e2e68692982806ab90c7879e0c7;p=dbsrgits%2FDBM-Deep.git diff --git a/t/23_misc.t b/t/23_misc.t index 5a6f179..c2137b8 100644 --- a/t/23_misc.t +++ b/t/23_misc.t @@ -2,27 +2,26 @@ # DBM::Deep Test ## use strict; -use Test::More; +use Test::More tests => 7; use Test::Exception; - -plan tests => 7; +use t::common qw( new_fh ); use_ok( 'DBM::Deep' ); -unlink "t/test.db"; -my $db = DBM::Deep->new( "t/test.db" ); +my ($fh, $filename) = new_fh(); +my $db = DBM::Deep->new( $filename ); $db->{key1} = "value1"; is( $db->{key1}, "value1", "Value set correctly" ); # Testing to verify that the close() will occur if open is called on an open DB. #XXX WOW is this hacky ... -$db->_get_self->{engine}->open( $db->_get_self ); +$db->_get_self->_fileobj->open; is( $db->{key1}, "value1", "Value still set after re-open" ); throws_ok { my $db = DBM::Deep->new( 't' ); -} qr/^DBM::Deep: Cannot sysopen file: t: /, "Can't open a file we aren't allowed to touch"; +} qr/^DBM::Deep: Cannot sysopen file 't': /, "Can't open a file we aren't allowed to touch"; throws_ok { my $db = DBM::Deep->new( __FILE__ ); @@ -30,19 +29,19 @@ throws_ok { { my $db = DBM::Deep->new( - file => 't/test.db', + file => $filename, locking => 1, ); - $db->_get_self->{engine}->close( $db->_get_self ); - ok( !$db->lock ); + $db->_get_self->_fileobj->close( $db->_get_self ); + ok( !$db->lock, "Calling lock() on a closed database returns false" ); } { my $db = DBM::Deep->new( - file => 't/test.db', + file => $filename, locking => 1, ); $db->lock; - $db->_get_self->{engine}->close( $db->_get_self ); - ok( !$db->unlock ); + $db->_get_self->_fileobj->close( $db->_get_self ); + ok( !$db->unlock, "Calling unlock() on a closed database returns false" ); }