X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=install%2F5.005%2FDBD-Pg-1.22-fixvercmp%2Ft%2F09autocommit.t;fp=install%2F5.005%2FDBD-Pg-1.22-fixvercmp%2Ft%2F09autocommit.t;h=9b1b69fc6534c4fc360ac444667d12a1758e757b;hp=0000000000000000000000000000000000000000;hb=ee146c3eada3bdb419ba471dd6df5e889d7dd7e5;hpb=c29fa7acc16efcc86af06077e739fca8b783c3c1 diff --git a/install/5.005/DBD-Pg-1.22-fixvercmp/t/09autocommit.t b/install/5.005/DBD-Pg-1.22-fixvercmp/t/09autocommit.t new file mode 100644 index 000000000..9b1b69fc6 --- /dev/null +++ b/install/5.005/DBD-Pg-1.22-fixvercmp/t/09autocommit.t @@ -0,0 +1,68 @@ +use strict; +use DBI; +use Test::More; + +if (defined $ENV{DBI_DSN}) { + plan tests => 12; +} else { + plan skip_all => 'cannot test without DB info'; +} + +my $dbh1 = DBI->connect($ENV{DBI_DSN}, $ENV{DBI_USER}, $ENV{DBI_PASS}, + {RaiseError => 1, AutoCommit => 1} + ); +ok(defined $dbh1, + 'connect first dbh' + ); + +my $dbh2 = DBI->connect($ENV{DBI_DSN}, $ENV{DBI_USER}, $ENV{DBI_PASS}, + {RaiseError => 1, AutoCommit => 1} + ); +ok(defined $dbh2, + 'connect second dbh' + ); + +ok($dbh1->do(q{DELETE FROM test}), + 'delete' + ); + +my $rows = ($dbh1->selectrow_array(q{SELECT COUNT(*) FROM test}))[0]; +ok($rows == 0, + 'fetch on empty table from dbh1' + ); + +$rows = ($dbh2->selectrow_array(q{SELECT COUNT(*) FROM test}))[0]; +ok($rows == 0, + 'fetch on empty table from dbh2' + ); + +ok($dbh1->do(q{INSERT INTO test (id, name, val) VALUES (1, 'foo', 'horse')}), + 'insert' + ); + +$rows = ($dbh1->selectrow_array(q{SELECT COUNT(*) FROM test}))[0]; +ok($rows == 1, + 'fetch one row from dbh1' + ); + +$rows = ($dbh2->selectrow_array(q{SELECT COUNT(*) FROM test}))[0]; +ok($rows == 1, + 'fetch one row from dbh1' + ); + +local $SIG{__WARN__} = sub {}; +ok(!$dbh1->commit(), + 'commit' + ); + +ok(!$dbh1->rollback(), + 'rollback' + ); + +ok($dbh1->disconnect(), + 'disconnect on dbh1' +); + +ok($dbh2->disconnect(), + 'disconnect on dbh2' +);