All tests pass except for the transaction tests under MySQL. InnoDB sucks
[dbsrgits/DBM-Deep.git] / t / 09_deeparray.t
index 7b8dab8..9bd883c 100644 (file)
@@ -1,43 +1,45 @@
-##
-# DBM::Deep Test
-##
-$|++;
 use strict;
+use warnings FATAL => 'all';
+
 use Test::More;
 
-my $max_levels = 1000;
+plan skip_all => "You must set \$ENV{LONG_TESTS} to run the long tests"
+    unless $ENV{LONG_TESTS};
+
+use t::common qw( new_dbm );
 
-plan tests => 3;
+diag "This test can take up to several minutes to run. Please be patient.";
 
 use_ok( 'DBM::Deep' );
 
-unlink "t/test.db";
-my $db = DBM::Deep->new(
-       file => "t/test.db",
-       type => DBM::Deep->TYPE_ARRAY,
-);
-
-$db->[0] = [];
-my $temp_db = $db->[0];
-for my $k ( 0 .. $max_levels ) {
-       $temp_db->[$k] = [];
-       $temp_db = $temp_db->[$k];
-}
-$temp_db->[0] = "deepvalue";
-undef $temp_db;
-
-undef $db;
-$db = DBM::Deep->new(
-       file => "t/test.db",
-       type => DBM::Deep->TYPE_ARRAY,
-);
-
-my $cur_level = -1;
-$temp_db = $db->[0];
-for my $k ( 0 .. $max_levels ) {
-    $cur_level = $k;
-    $temp_db = $temp_db->[$k];
-    eval { $temp_db->isa( 'DBM::Deep' ) } or last;
+my $dbm_factory = new_dbm( type => DBM::Deep->TYPE_ARRAY );
+while ( my $dbm_maker = $dbm_factory->() ) {
+    my $max_levels = 1000;
+
+    {
+        my $db = $dbm_maker->();
+
+        $db->[0] = [];
+        my $temp_db = $db->[0];
+        for my $k ( 0 .. $max_levels ) {
+            $temp_db->[$k] = [];
+            $temp_db = $temp_db->[$k];
+        }
+        $temp_db->[0] = "deepvalue";
+    }
+
+    {
+        my $db = $dbm_maker->();
+
+        my $cur_level = -1;
+        my $temp_db = $db->[0];
+        for my $k ( 0 .. $max_levels ) {
+            $cur_level = $k;
+            $temp_db = $temp_db->[$k];
+            eval { $temp_db->isa( 'DBM::Deep' ) } or last;
+        }
+        is( $cur_level, $max_levels, "We read all the way down to level $cur_level" );
+        is( $temp_db->[0], "deepvalue", "And we retrieved the value at the bottom of the ocean" );
+    }
 }
-is( $cur_level, $max_levels, "We read all the way down to level $cur_level" );
-is( $temp_db->[0], "deepvalue", "And we retrieved the value at the bottom of the ocean" );
+done_testing;