pg: Better error reporting + basic exec() method
This commit is contained in:
parent
b242176071
commit
c51b5f3598
5 changed files with 173 additions and 28 deletions
|
|
@ -4,7 +4,15 @@ use Test::More;
|
|||
plan skip_all => $@ if !eval { require FU::PG; } && $@ =~ /Unable to load libpq/;
|
||||
plan skip_all => 'Please set FU_TEST_DB to a PostgreSQL connection string to run these tests' if !$ENV{FU_TEST_DB};
|
||||
|
||||
sub okerr($sev, $act, $msg) {
|
||||
is ref $@, 'FU::PG::error';
|
||||
is $@->{severity}, $sev;
|
||||
is $@->{action}, $act;
|
||||
like "$@", $msg;
|
||||
}
|
||||
|
||||
ok !eval { FU::PG->connect("invalid") };
|
||||
okerr FATAL => connect => qr/missing "=" after "invalid"/;
|
||||
|
||||
ok FU::PG::lib_version() > 100000;
|
||||
|
||||
|
|
@ -14,4 +22,13 @@ is ref $conn, 'FU::PG::conn';
|
|||
ok $conn->server_version() > 100000;
|
||||
is $conn->lib_version(), FU::PG::lib_version();
|
||||
|
||||
ok !eval { $conn->exec('COPY (SELECT 1) TO STDOUT'); };
|
||||
okerr FATAL => exec => qr/unexpected status code/;
|
||||
|
||||
ok !eval { $conn->exec('SELEXT'); };
|
||||
okerr ERROR => exec => qr/syntax error/;
|
||||
|
||||
ok !defined $conn->exec('');
|
||||
is $conn->exec('SELECT 1'), 1;
|
||||
|
||||
done_testing;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue