mirror of
https://github.com/postgres/postgres.git
synced 2026-02-25 02:44:39 -05:00
This makes the psql() method much more capable: it captures both stdout and stderr; it now returns the psql exit code rather than stdout; a timeout can now be specified, as can ON_ERROR_STOP behavior; it gained a new "on_error_die" (defaulting to off) parameter to raise an exception if there's any problem. Finally, additional parameters to psql can be passed if there's need for further tweaking. For convenience, a new safe_psql() method retains much of the old behavior of psql(), except that it uses on_error_die on, so that problems like syntax errors in SQL commands can be detected more easily. Many existing TAP test files now use safe_psql, which is what is really wanted. A couple of ->psql() calls are now added in the commit_ts tests, which verify that the right thing is happening on certain errors. Some ->command_fails() calls in recovery tests that were verifying that psql failed also became ->psql() calls now. Author: Craig Ringer. Some tweaks by Álvaro Herrera Reviewed-By: Michaël Paquier
23 lines
506 B
Perl
23 lines
506 B
Perl
use strict;
|
|
use warnings;
|
|
|
|
use PostgresNode;
|
|
use TestLib;
|
|
use Test::More tests => 11;
|
|
|
|
program_help_ok('dropdb');
|
|
program_version_ok('dropdb');
|
|
program_options_handling_ok('dropdb');
|
|
|
|
my $node = get_new_node('main');
|
|
$node->init;
|
|
$node->start;
|
|
|
|
$node->safe_psql('postgres', 'CREATE DATABASE foobar1');
|
|
$node->issues_sql_like(
|
|
[ 'dropdb', 'foobar1' ],
|
|
qr/statement: DROP DATABASE foobar1/,
|
|
'SQL DROP DATABASE run');
|
|
|
|
$node->command_fails([ 'dropdb', 'nonexistent' ],
|
|
'fails with nonexistent database');
|