X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F23_misc.t;h=c2137b8f973722cd0f27751e7b9f221d84fbf905;hb=7a960a129d8c03a7bc83325f2f8be78a0881d034;hp=e206ff36057c9cfa44834f3df707fe309564e22e;hpb=ebbe409358f168ae4fb913232f5c9b76e378d276;p=dbsrgits%2FDBM-Deep.git diff --git a/t/23_misc.t b/t/23_misc.t index e206ff3..c2137b8 100644 --- a/t/23_misc.t +++ b/t/23_misc.t @@ -2,52 +2,46 @@ # 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" ); -if ($db->error()) { - die "ERROR: " . $db->error(); -} +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. -$db->_open; - +#XXX WOW is this hacky ... +$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 open 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__ ); } qr/^DBM::Deep: Signature not found -- file is not a Deep DB/, "Only DBM::Deep DB files will be opened"; -TODO: { - todo_skip "lock() doesn't check to see if the file is open", 1; +{ my $db = DBM::Deep->new( - file => 't/test.db', + file => $filename, locking => 1, ); - $db->_close; - ok( !$db->lock ); + $db->_get_self->_fileobj->close( $db->_get_self ); + ok( !$db->lock, "Calling lock() on a closed database returns false" ); } -TODO: { - todo_skip "unlock() doesn't check to see if the file is open", 1; +{ my $db = DBM::Deep->new( - file => 't/test.db', + file => $filename, locking => 1, ); $db->lock; - $db->_close; - ok( !$db->unlock ); + $db->_get_self->_fileobj->close( $db->_get_self ); + ok( !$db->unlock, "Calling unlock() on a closed database returns false" ); }