Added failing test for large numbers of transactions
rkinyon [Tue, 30 Jan 2007 05:25:55 +0000 (05:25 +0000)]
MANIFEST
t/43_transaction_maximum.t [new file with mode: 0644]

index bbc9e25..3c4d1b2 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -54,4 +54,5 @@ t/39_singletons.t
 t/40_freespace.t
 t/41_transaction_multilevel.t
 t/42_transaction_indexsector.t
+t/43_transaction_maximum.t
 t/common.pm
diff --git a/t/43_transaction_maximum.t b/t/43_transaction_maximum.t
new file mode 100644 (file)
index 0000000..95aba68
--- /dev/null
@@ -0,0 +1,38 @@
+use strict;
+use Test::More;
+use Test::Deep;
+use Test::Exception;
+use t::common qw( new_fh );
+
+use DBM::Deep;
+
+my $max_txns = 255;
+
+my ($fh, $filename) = new_fh();
+
+my @dbs = grep { $_ } map {
+    eval {
+        DBM::Deep->new(
+            file => $filename,
+            num_txns  => $max_txns,
+        );
+    };
+} 1 .. $max_txns;
+
+my $num = $#dbs;
+
+plan tests => do {
+    my $n = $num + 1;
+    2 * $n;
+};
+
+my %trans_ids;
+for my $n (0 .. $num) {
+    lives_ok {
+        $dbs[$n]->begin_work
+    } "DB $n can begin_work";
+
+    my $trans_id = $dbs[$n]->_engine->trans_id, $/;
+    ok( !exists $trans_ids{ $trans_id }, "DB $n has a unique transaction ID" );
+    $trans_ids{ $trans_id } = $n;
+}