Prepare for 1.0020
[dbsrgits/DBM-Deep.git] / t / 43_transaction_maximum.t
1 use strict;
2 use warnings FATAL => 'all';
3
4 use Test::More;
5 use Test::Deep;
6 use Test::Exception;
7 use t::common qw( new_dbm );
8
9 use_ok( 'DBM::Deep' );
10
11 my $max_txns = 220;
12
13 my $dbm_factory = new_dbm(
14     num_txns  => $max_txns,
15 );
16 while ( my $dbm_maker = $dbm_factory->() ) {
17     my @dbs = ( $dbm_maker->() );
18     next unless $dbs[0]->supports('transactions');
19
20     push @dbs, grep { $_ } map {
21         eval { $dbm_maker->() }
22     } 2 .. $max_txns;
23
24     cmp_ok( scalar(@dbs), '==', $max_txns, "We could open enough DB handles" );
25
26     my %trans_ids;
27     for my $n (0 .. $#dbs) {
28         lives_ok {
29             $dbs[$n]->begin_work
30         } "DB $n can begin_work";
31
32         my $trans_id = $dbs[$n]->_engine->trans_id;
33         ok( !exists $trans_ids{ $trans_id }, "DB $n has a unique transaction ID ($trans_id)" );
34         $trans_ids{ $trans_id } = $n;
35     }
36 }
37
38 done_testing;