Option to disable the charging of the setup fee while a package is suspended.
[freeside.git] / install / 5.005 / DBD-Pg-1.22-fixvercmp / t / 09autocommit.t
1 use strict;
2 use DBI;
3 use Test::More;
4
5 if (defined $ENV{DBI_DSN}) {
6   plan tests => 12;
7 } else {
8   plan skip_all => 'cannot test without DB info';
9 }
10
11 my $dbh1 = DBI->connect($ENV{DBI_DSN}, $ENV{DBI_USER}, $ENV{DBI_PASS},
12                         {RaiseError => 1, AutoCommit => 1}
13                        );
14 ok(defined $dbh1,
15    'connect first dbh'
16   );
17
18 my $dbh2 = DBI->connect($ENV{DBI_DSN}, $ENV{DBI_USER}, $ENV{DBI_PASS},
19                         {RaiseError => 1, AutoCommit => 1}
20                        );
21 ok(defined $dbh2,
22    'connect second dbh'
23   );
24
25 ok($dbh1->do(q{DELETE FROM test}),
26    'delete'
27   );
28
29 my $rows = ($dbh1->selectrow_array(q{SELECT COUNT(*) FROM test}))[0];
30 ok($rows == 0,
31    'fetch on empty table from dbh1'
32   );
33
34 $rows = ($dbh2->selectrow_array(q{SELECT COUNT(*) FROM test}))[0];
35 ok($rows == 0,
36    'fetch on empty table from dbh2'
37   );
38
39 ok($dbh1->do(q{INSERT INTO test (id, name, val) VALUES (1, 'foo', 'horse')}),
40    'insert'
41   );
42
43 $rows = ($dbh1->selectrow_array(q{SELECT COUNT(*) FROM test}))[0];
44 ok($rows == 1,
45    'fetch one row from dbh1'
46   );
47
48 $rows = ($dbh2->selectrow_array(q{SELECT COUNT(*) FROM test}))[0];
49 ok($rows == 1,
50    'fetch one row from dbh1'
51   );
52
53 local $SIG{__WARN__} = sub {};
54 ok(!$dbh1->commit(),
55    'commit'
56   );
57
58 ok(!$dbh1->rollback(),
59    'rollback'
60   );
61
62 ok($dbh1->disconnect(),
63    'disconnect on dbh1'
64 );
65
66 ok($dbh2->disconnect(),
67    'disconnect on dbh2'
68 );