Started migration to Test::Class
[dbsrgits/DBM-Deep.git] / t / 11_optimize.t
index cbc5910..27d2058 100644 (file)
@@ -3,12 +3,13 @@
 ##
 use strict;
 use Test::More tests => 9;
+use File::Temp qw( tmpnam );
 
 use_ok( 'DBM::Deep' );
 
-unlink "t/test.db";
+my $filename = tmpnam();
 my $db = DBM::Deep->new(
-       file => "t/test.db",
+       file => $filename,
        autoflush => 1,
 );
 
@@ -52,6 +53,8 @@ ok( $after < $before, "file size has shrunk" ); # make sure file shrunk
 is( $db->{key1}, 'value1', "key1's value is still there after optimize" );
 is( $db->{a}{c}, 'value2', "key2's value is still there after optimize" );
 
+#print keys %{$db->{a}}, $/;
+
 ##
 # now for the tricky one -- try to store a new key while file is being
 # optimized and locked by another process.  filehandle should be invalidated, 
@@ -79,7 +82,7 @@ SKIP: {
         
         # re-open db
         $db = DBM::Deep->new(
-            file => "t/test.db",
+            file => $filename,
             autoflush => 1,
             locking => 1
         );
@@ -95,7 +98,7 @@ SKIP: {
     
     # re-open db
     $db = DBM::Deep->new(
-        file => "t/test.db",
+        file => $filename,
         autoflush => 1,
         locking => 1
     );
@@ -108,7 +111,13 @@ SKIP: {
     
     # see if it was stored successfully
     is( $db->{parentfork}, "hello", "stored key while optimize took place" );
-    # ok(1);
+
+#    undef $db;
+#    $db = DBM::Deep->new(
+#        file => $filename,
+#        autoflush => 1,
+#        locking => 1
+#    );
     
     # now check some existing values from before
     is( $db->{key1}, 'value1', "key1's value is still there after optimize" );