From: rkinyon Date: Wed, 1 Mar 2006 20:48:00 +0000 (+0000) Subject: added test for freespace management X-Git-Tag: 0-99_01~95 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a21f2d90935286a81dbaa6299707e140060e52d3;p=dbsrgits%2FDBM-Deep.git added test for freespace management --- diff --git a/Build.PL b/Build.PL index 18173d8..dddb76b 100644 --- a/Build.PL +++ b/Build.PL @@ -14,6 +14,7 @@ my $build = Module::Build->new( build_requires => { 'Test::More' => '0.47', 'Test::Exception' => '0.21', + 'File::Temp' => '0.01', }, create_makefile_pl => 'traditional', add_to_cleanup => [ diff --git a/MANIFEST b/MANIFEST index 7edec17..527ac48 100644 --- a/MANIFEST +++ b/MANIFEST @@ -37,3 +37,4 @@ t/26_scalar_ref.t t/27_filehandle.t t/27_filehandle.t.db t/28_DATA.t +t/29_freespace_manager.t diff --git a/lib/DBM/Deep/Engine.pm b/lib/DBM/Deep/Engine.pm index eb3f5c5..7c8d139 100644 --- a/lib/DBM/Deep/Engine.pm +++ b/lib/DBM/Deep/Engine.pm @@ -190,7 +190,7 @@ sub open { sub close_fh { my $self = shift; - my $obj = shift; + my ($obj) = @_; if ( my $fh = $obj->_root->{fh} ) { close $fh; diff --git a/t/29_freespace_manager.t b/t/29_freespace_manager.t new file mode 100644 index 0000000..d6b18fb --- /dev/null +++ b/t/29_freespace_manager.t @@ -0,0 +1,31 @@ +use strict; + +use Test::More tests => 3; +use File::Temp qw( tempfile ); + +use_ok( 'DBM::Deep' ); + +my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1 ); +my $db = DBM::Deep->new({ + file => $filename, + autoflush => 1, +}); + +$db->{foo} = 'abcd'; + +my $s1 = -s $filename; + +delete $db->{foo}; + +my $s2 = -s $filename; + +is( $s2, $s1, "delete doesn't recover freespace" ); + +$db->{bar} = 'a'; + +my $s3 = -s $filename; + +TODO: { + local $TODO = "Freespace manager doesn't work yet"; + is( $s3, $s1, "Freespace is reused" ); +}