summaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/t/001_basic.pl
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/pg_dump/t/001_basic.pl')
-rw-r--r--src/bin/pg_dump/t/001_basic.pl128
1 files changed, 85 insertions, 43 deletions
diff --git a/src/bin/pg_dump/t/001_basic.pl b/src/bin/pg_dump/t/001_basic.pl
index 2bbf850ff3f..9a3e7451658 100644
--- a/src/bin/pg_dump/t/001_basic.pl
+++ b/src/bin/pg_dump/t/001_basic.pl
@@ -4,7 +4,7 @@ use warnings;
use Config;
use PostgresNode;
use TestLib;
-use Test::More tests => 42;
+use Test::More tests => 70;
my $tempdir = TestLib::tempdir;
my $tempdir_short = TestLib::tempdir_short;
@@ -28,82 +28,124 @@ program_options_handling_ok('pg_dumpall');
# Test various invalid options and disallowed combinations
# Doesn't require a PG instance to be set up, so do this first.
-command_exit_is([ 'pg_dump', 'qqq', 'abc' ],
- 1, 'pg_dump: too many command-line arguments (first is "asd")');
+command_fails_like(
+ [ 'pg_dump', 'qqq', 'abc' ],
+ qr/\Qpg_dump: too many command-line arguments (first is "abc")\E/,
+ 'pg_dump: too many command-line arguments (first is "asd")');
-command_exit_is([ 'pg_restore', 'qqq', 'abc' ],
- 1, 'pg_restore too many command-line arguments (first is "asd")');
+command_fails_like(
+ [ 'pg_restore', 'qqq', 'abc' ],
+ qr/\Qpg_restore: too many command-line arguments (first is "abc")\E/,
+ 'pg_restore too many command-line arguments (first is "abc")');
-command_exit_is([ 'pg_dumpall', 'qqq', 'abc' ],
- 1, 'pg_dumpall: too many command-line arguments (first is "qqq")');
+command_fails_like(
+ [ 'pg_dumpall', 'qqq', 'abc' ],
+ qr/\Qpg_dumpall: too many command-line arguments (first is "qqq")\E/,
+ 'pg_dumpall: too many command-line arguments (first is "qqq")');
-command_exit_is(
+command_fails_like(
[ 'pg_dump', '-s', '-a' ],
- 1,
+qr/\Qpg_dump: options -s\/--schema-only and -a\/--data-only cannot be used together\E/,
'pg_dump: options -s/--schema-only and -a/--data-only cannot be used together'
);
-command_exit_is(
+command_fails_like(
[ 'pg_restore', '-s', '-a' ],
- 1,
+qr/\Qpg_restore: options -s\/--schema-only and -a\/--data-only cannot be used together\E/,
'pg_restore: options -s/--schema-only and -a/--data-only cannot be used together'
);
-command_exit_is([ 'pg_restore', '-d', 'xxx', '-f', 'xxx' ],
- 1,
+command_fails_like(
+ [ 'pg_restore', '-d', 'xxx', '-f', 'xxx' ],
+qr/\Qpg_restore: options -d\/--dbname and -f\/--file cannot be used together\E/,
'pg_restore: options -d/--dbname and -f/--file cannot be used together');
-command_exit_is(
+command_fails_like(
[ 'pg_dump', '-c', '-a' ],
- 1,
+qr/\Qpg_dump: options -c\/--clean and -a\/--data-only cannot be used together\E/,
'pg_dump: options -c/--clean and -a/--data-only cannot be used together');
-command_exit_is(
+command_fails_like(
[ 'pg_restore', '-c', '-a' ],
- 1,
+qr/\Qpg_restore: options -c\/--clean and -a\/--data-only cannot be used together\E/,
'pg_restore: options -c/--clean and -a/--data-only cannot be used together');
-command_exit_is(
+command_fails_like(
[ 'pg_dump', '--inserts', '-o' ],
- 1,
+qr/\Qpg_dump: options --inserts\/--column-inserts and -o\/--oids cannot be used together\E/,
'pg_dump: options --inserts/--column-inserts and -o/--oids cannot be used together'
);
-command_exit_is([ 'pg_dump', '--if-exists' ],
- 1, 'pg_dump: option --if-exists requires option -c/--clean');
-
-command_exit_is([ 'pg_dump', '-j' ],
- 1, 'pg_dump: option requires an argument -- \'j\'');
-
-command_exit_is([ 'pg_dump', '-j3' ],
- 1, 'pg_dump: parallel backup only supported by the directory format');
-
-command_exit_is(
+command_fails_like(
+ [ 'pg_dump', '--if-exists' ],
+ qr/\Qpg_dump: option --if-exists requires option -c\/--clean\E/,
+ 'pg_dump: option --if-exists requires option -c/--clean');
+
+command_fails_like(
+ [ 'pg_dump', '-j' ],
+ qr/\Qpg_dump: option requires an argument -- 'j'\E/,
+ 'pg_dump: option requires an argument -- \'j\'');
+
+command_fails_like(
+ [ 'pg_dump', '-j3' ],
+ qr/\Qpg_dump: parallel backup only supported by the directory format\E/,
+ 'pg_dump: parallel backup only supported by the directory format');
+
+command_fails_like(
+ [ 'pg_dump', '-j', '-1' ],
+ qr/\Qpg_dump: invalid number of parallel jobs\E/,
+ 'pg_dump: invalid number of parallel jobs');
+
+command_fails_like(
+ [ 'pg_dump', '-F', 'garbage' ],
+ qr/\Qpg_dump: invalid output format\E/,
+ 'pg_dump: invalid output format');
+
+command_fails_like(
+ [ 'pg_restore', '-j', '-1' ],
+ qr/\Qpg_restore: invalid number of parallel jobs\E/,
+ 'pg_restore: invalid number of parallel jobs');
+
+command_fails_like(
[ 'pg_restore', '--single-transaction', '-j3' ],
- 1,
+qr/\Qpg_restore: cannot specify both --single-transaction and multiple jobs\E/,
'pg_restore: cannot specify both --single-transaction and multiple jobs');
-command_exit_is([ 'pg_restore', '--if-exists' ],
- 1, 'pg_restore: option --if-exists requires option -c/--clean');
+command_fails_like(
+ [ 'pg_dump', '-Z', '-1' ],
+ qr/\Qpg_dump: compression level must be in range 0..9\E/,
+ 'pg_dump: compression level must be in range 0..9');
+
+command_fails_like(
+ [ 'pg_restore', '--if-exists' ],
+ qr/\Qpg_restore: option --if-exists requires option -c\/--clean\E/,
+ 'pg_restore: option --if-exists requires option -c/--clean');
+
+command_fails_like(
+ [ 'pg_restore', '-F', 'garbage' ],
+ qr/\Qpg_restore: unrecognized archive format "garbage";\E/,
+ 'pg_dump: unrecognized archive format');
# pg_dumpall command-line argument checks
-command_exit_is(
+command_fails_like(
[ 'pg_dumpall', '-g', '-r' ],
- 1,
-'pg_restore: options -g/--globals-only and -r/--roles-only cannot be used together'
+qr/\Qpg_dumpall: options -g\/--globals-only and -r\/--roles-only cannot be used together\E/,
+'pg_dumpall: options -g/--globals-only and -r/--roles-only cannot be used together'
);
-command_exit_is(
+command_fails_like(
[ 'pg_dumpall', '-g', '-t' ],
- 1,
-'pg_restore: options -g/--globals-only and -t/--tablespaces-only cannot be used together'
+qr/\Qpg_dumpall: options -g\/--globals-only and -t\/--tablespaces-only cannot be used together\E/,
+'pg_dumpall: options -g/--globals-only and -t/--tablespaces-only cannot be used together'
);
-command_exit_is(
+command_fails_like(
[ 'pg_dumpall', '-r', '-t' ],
- 1,
-'pg_restore: options -r/--roles-only and -t/--tablespaces-only cannot be used together'
+qr/\Qpg_dumpall: options -r\/--roles-only and -t\/--tablespaces-only cannot be used together\E/,
+'pg_dumpall: options -r/--roles-only and -t/--tablespaces-only cannot be used together'
);
-command_exit_is([ 'pg_dumpall', '--if-exists' ],
- 1, 'pg_dumpall: option --if-exists requires option -c/--clean');
+command_fails_like(
+ [ 'pg_dumpall', '--if-exists' ],
+ qr/\Qpg_dumpall: option --if-exists requires option -c\/--clean\E/,
+ 'pg_dumpall: option --if-exists requires option -c/--clean');