From: rkinyon Date: Wed, 1 Mar 2006 21:42:00 +0000 (+0000) Subject: Removed last holdouts of t/test?.db X-Git-Tag: 0-99_01~93 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=98ac82afade6822238f9a0aee8900bc9365096e3;p=dbsrgits%2FDBM-Deep.git Removed last holdouts of t/test?.db --- diff --git a/t/15_digest.t b/t/15_digest.t index ee2853c..485052e 100644 --- a/t/15_digest.t +++ b/t/15_digest.t @@ -88,13 +88,6 @@ $db->put("key1", "value222222222222222222222222"); ok( $db->get("key1") eq "value222222222222222222222222" ); -## -# close, delete file, exit -## -undef $db; -unlink "t/test.db"; -exit(0); - sub my_digest { ## # Warning: This digest function is for testing ONLY diff --git a/t/19_crossref.t b/t/19_crossref.t index 626873c..e01810c 100644 --- a/t/19_crossref.t +++ b/t/19_crossref.t @@ -3,38 +3,36 @@ ## use strict; use Test::More tests => 5; +use File::Temp qw( tempfile tempdir ); use_ok( 'DBM::Deep' ); -unlink "t/test.db"; -my $db = DBM::Deep->new( "t/test.db" ); - -unlink "t/test2.db"; -my $db2 = DBM::Deep->new( "t/test2.db" ); - -## -# Create structure in $db -## -$db->import( - hash1 => { - subkey1 => "subvalue1", - subkey2 => "subvalue2" - } -); - -is( $db->{hash1}{subkey1}, 'subvalue1', "Value imported correctly" ); -is( $db->{hash1}{subkey2}, 'subvalue2', "Value imported correctly" ); - -## -# Cross-ref nested hash accross DB objects -## -$db2->{copy} = $db->{hash1}; - -## -# close, delete $db -## -undef $db; -unlink "t/test.db"; +my $dir = tempdir( CLEANUP => 1 ); +my ($fh2, $filename2) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +my $db2 = DBM::Deep->new( $filename2 ); + +{ + my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); + my $db = DBM::Deep->new( $filename ); + + ## + # Create structure in $db + ## + $db->import( + hash1 => { + subkey1 => "subvalue1", + subkey2 => "subvalue2" + } + ); + + is( $db->{hash1}{subkey1}, 'subvalue1', "Value imported correctly" ); + is( $db->{hash1}{subkey2}, 'subvalue2', "Value imported correctly" ); + + ## + # Cross-ref nested hash accross DB objects + ## + $db2->{copy} = $db->{hash1}; +} ## # Make sure $db2 has copy of $db's hash structure diff --git a/t/20_tie.t b/t/20_tie.t index 4ad4cb9..7e2e665 100644 --- a/t/20_tie.t +++ b/t/20_tie.t @@ -58,17 +58,14 @@ throws_ok { tie my %hash, 'DBM::Deep', [ file => $filename ]; } qr/Not a hashref/, "Passing an arrayref to TIEHASH fails"; -unlink "t/test.db"; throws_ok { tie my @array, 'DBM::Deep', [ file => $filename ]; } qr/Not a hashref/, "Passing an arrayref to TIEARRAY fails"; -unlink "t/test.db"; throws_ok { tie my %hash, 'DBM::Deep', undef, file => $filename; } qr/Odd number of parameters/, "Odd number of params to TIEHASH fails"; -unlink "t/test.db"; throws_ok { tie my @array, 'DBM::Deep', undef, file => $filename; } qr/Odd number of parameters/, "Odd number of params to TIEARRAY fails"; diff --git a/t/22_internal_copy.t b/t/22_internal_copy.t index 000519f..e75ac0c 100644 --- a/t/22_internal_copy.t +++ b/t/22_internal_copy.t @@ -3,11 +3,13 @@ ## use strict; use Test::More tests => 13; +use File::Temp qw( tempfile tempdir ); use_ok( 'DBM::Deep' ); -unlink "t/test.db"; -my $db = DBM::Deep->new( "t/test.db" ); +my $dir = tempdir( CLEANUP => 1 ); +my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +my $db = DBM::Deep->new( $filename ); ## # Create structure in $db @@ -47,9 +49,9 @@ is( $db->{copy}{subkey3}, 'subvalue3', "After the second copy, we're still good" my $max_keys = 1000; -unlink 't/test2.db'; +my ($fh2, $filename2) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); { - my $db = DBM::Deep->new( 't/test2.db' ); + my $db = DBM::Deep->new( $filename2 ); $db->{foo} = [ 1 .. 3 ]; for ( 0 .. $max_keys ) { @@ -58,7 +60,7 @@ unlink 't/test2.db'; } { - my $db = DBM::Deep->new( 't/test2.db' ); + my $db = DBM::Deep->new( $filename2 ); my $base_offset = $db->{foo}->_base_offset; my $count = -1;