All tests pass except for the transaction tests under MySQL. InnoDB sucks
[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
4f034d8f 13if ( $ENV{NO_TEST_TRANSACTIONS} ) {
14 done_testing;
15 exit;
16}
17
0e3e3555 18my $dbm_factory = new_dbm(
19 num_txns => $max_txns,
20);
21while ( my $dbm_maker = $dbm_factory->() ) {
22 my @dbs = grep { $_ } map {
23 eval { $dbm_maker->() }
24 } 1 .. $max_txns;
25
26
27 cmp_ok( scalar(@dbs), '==', $max_txns, "We could open enough DB handles" );
28
29 my %trans_ids;
30 for my $n (0 .. $#dbs) {
31 lives_ok {
32 $dbs[$n]->begin_work
33 } "DB $n can begin_work";
34
35 my $trans_id = $dbs[$n]->_engine->trans_id;
36 ok( !exists $trans_ids{ $trans_id }, "DB $n has a unique transaction ID ($trans_id)" );
37 $trans_ids{ $trans_id } = $n;
38 }
e9b0b5f0 39}
0e3e3555 40
41done_testing;