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