mirror of
https://github.com/postgres/postgres.git
synced 2025-05-30 00:02:11 -04:00
Add basic pg_dumpall/pg_restore TAP tests
For reasons unknown, pg_dumpall and pg_restore managed to escape the basic set of TAP tests that were added for pg_dump in 6bd356c3, so let's get them added now. A few minor adjustments are also made to the dump/restore tests to improve code coverage for pg_restore/pg_dumpall.
This commit is contained in:
parent
de5fed0d0c
commit
9b815a8ff2
@ -4,7 +4,7 @@ use warnings;
|
|||||||
use Config;
|
use Config;
|
||||||
use PostgresNode;
|
use PostgresNode;
|
||||||
use TestLib;
|
use TestLib;
|
||||||
use Test::More tests => 15;
|
use Test::More tests => 42;
|
||||||
|
|
||||||
my $tempdir = TestLib::tempdir;
|
my $tempdir = TestLib::tempdir;
|
||||||
my $tempdir_short = TestLib::tempdir_short;
|
my $tempdir_short = TestLib::tempdir_short;
|
||||||
@ -16,6 +16,14 @@ program_help_ok('pg_dump');
|
|||||||
program_version_ok('pg_dump');
|
program_version_ok('pg_dump');
|
||||||
program_options_handling_ok('pg_dump');
|
program_options_handling_ok('pg_dump');
|
||||||
|
|
||||||
|
program_help_ok('pg_restore');
|
||||||
|
program_version_ok('pg_restore');
|
||||||
|
program_options_handling_ok('pg_restore');
|
||||||
|
|
||||||
|
program_help_ok('pg_dumpall');
|
||||||
|
program_version_ok('pg_dumpall');
|
||||||
|
program_options_handling_ok('pg_dumpall');
|
||||||
|
|
||||||
#########################################
|
#########################################
|
||||||
# Test various invalid options and disallowed combinations
|
# Test various invalid options and disallowed combinations
|
||||||
# Doesn't require a PG instance to be set up, so do this first.
|
# Doesn't require a PG instance to be set up, so do this first.
|
||||||
@ -23,17 +31,40 @@ program_options_handling_ok('pg_dump');
|
|||||||
command_exit_is([ 'pg_dump', 'qqq', 'abc' ],
|
command_exit_is([ 'pg_dump', 'qqq', 'abc' ],
|
||||||
1, 'pg_dump: too many command-line arguments (first is "asd")');
|
1, '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_exit_is([ 'pg_dumpall', 'qqq', 'abc' ],
|
||||||
|
1, 'pg_dumpall: too many command-line arguments (first is "qqq")');
|
||||||
|
|
||||||
command_exit_is(
|
command_exit_is(
|
||||||
[ 'pg_dump', '-s', '-a' ],
|
[ 'pg_dump', '-s', '-a' ],
|
||||||
1,
|
1,
|
||||||
'pg_dump: options -s/--schema-only and -a/--data-only cannot be used together'
|
'pg_dump: options -s/--schema-only and -a/--data-only cannot be used together'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
command_exit_is(
|
||||||
|
[ 'pg_restore', '-s', '-a' ],
|
||||||
|
1,
|
||||||
|
'pg_restore: options -s/--schema-only and -a/--data-only cannot be used together'
|
||||||
|
);
|
||||||
|
|
||||||
|
command_exit_is(
|
||||||
|
[ 'pg_restore', '-d', 'xxx', '-f', 'xxx' ],
|
||||||
|
1,
|
||||||
|
'pg_restore: options -d/--dbname and -f/--file cannot be used together'
|
||||||
|
);
|
||||||
|
|
||||||
command_exit_is(
|
command_exit_is(
|
||||||
[ 'pg_dump', '-c', '-a' ],
|
[ 'pg_dump', '-c', '-a' ],
|
||||||
1,
|
1,
|
||||||
'pg_dump: options -c/--clean and -a/--data-only cannot be used together');
|
'pg_dump: options -c/--clean and -a/--data-only cannot be used together');
|
||||||
|
|
||||||
|
command_exit_is(
|
||||||
|
[ 'pg_restore', '-c', '-a' ],
|
||||||
|
1,
|
||||||
|
'pg_restore: options -c/--clean and -a/--data-only cannot be used together');
|
||||||
|
|
||||||
command_exit_is(
|
command_exit_is(
|
||||||
[ 'pg_dump', '--inserts', '-o' ],
|
[ 'pg_dump', '--inserts', '-o' ],
|
||||||
1,
|
1,
|
||||||
@ -48,3 +79,31 @@ command_exit_is([ 'pg_dump', '-j' ],
|
|||||||
|
|
||||||
command_exit_is([ 'pg_dump', '-j3' ],
|
command_exit_is([ 'pg_dump', '-j3' ],
|
||||||
1, 'pg_dump: parallel backup only supported by the directory format');
|
1, 'pg_dump: parallel backup only supported by the directory format');
|
||||||
|
|
||||||
|
command_exit_is([ 'pg_restore', '--single-transaction', '-j3' ],
|
||||||
|
1, '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');
|
||||||
|
|
||||||
|
# pg_dumpall command-line argument checks
|
||||||
|
command_exit_is(
|
||||||
|
[ 'pg_dumpall', '-g', '-r' ],
|
||||||
|
1,
|
||||||
|
'pg_restore: options -g/--globals-only and -r/--roles-only cannot be used together'
|
||||||
|
);
|
||||||
|
|
||||||
|
command_exit_is(
|
||||||
|
[ 'pg_dumpall', '-g', '-t' ],
|
||||||
|
1,
|
||||||
|
'pg_restore: options -g/--globals-only and -t/--tablespaces-only cannot be used together'
|
||||||
|
);
|
||||||
|
|
||||||
|
command_exit_is(
|
||||||
|
[ 'pg_dumpall', '-r', '-t' ],
|
||||||
|
1,
|
||||||
|
'pg_restore: 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');
|
||||||
|
@ -88,7 +88,7 @@ my %pgdump_runs = (
|
|||||||
"$tempdir/defaults_custom_format.dump", 'postgres', ],
|
"$tempdir/defaults_custom_format.dump", 'postgres', ],
|
||||||
restore_cmd => [
|
restore_cmd => [
|
||||||
'pg_restore',
|
'pg_restore',
|
||||||
'-f',
|
'-Fc', '-f',
|
||||||
"$tempdir/defaults_custom_format.sql",
|
"$tempdir/defaults_custom_format.sql",
|
||||||
"$tempdir/defaults_custom_format.dump", ], },
|
"$tempdir/defaults_custom_format.dump", ], },
|
||||||
defaults_dir_format => {
|
defaults_dir_format => {
|
||||||
@ -98,7 +98,7 @@ my %pgdump_runs = (
|
|||||||
'postgres', ],
|
'postgres', ],
|
||||||
restore_cmd => [
|
restore_cmd => [
|
||||||
'pg_restore',
|
'pg_restore',
|
||||||
'-f',
|
'-Fd', '-f',
|
||||||
"$tempdir/defaults_dir_format.sql",
|
"$tempdir/defaults_dir_format.sql",
|
||||||
"$tempdir/defaults_dir_format", ], },
|
"$tempdir/defaults_dir_format", ], },
|
||||||
defaults_parallel => {
|
defaults_parallel => {
|
||||||
@ -117,7 +117,7 @@ my %pgdump_runs = (
|
|||||||
'postgres', ],
|
'postgres', ],
|
||||||
restore_cmd => [
|
restore_cmd => [
|
||||||
'pg_restore',
|
'pg_restore',
|
||||||
'-f',
|
'-Ft', '-f',
|
||||||
"$tempdir/defaults_tar_format.sql",
|
"$tempdir/defaults_tar_format.sql",
|
||||||
"$tempdir/defaults_tar_format.tar", ], },
|
"$tempdir/defaults_tar_format.tar", ], },
|
||||||
exclude_dump_test_schema => {
|
exclude_dump_test_schema => {
|
||||||
@ -136,7 +136,7 @@ my %pgdump_runs = (
|
|||||||
'--exclude-table-data=dump_test.test_table', 'postgres', ], },
|
'--exclude-table-data=dump_test.test_table', 'postgres', ], },
|
||||||
pg_dumpall_globals => {
|
pg_dumpall_globals => {
|
||||||
dump_cmd =>
|
dump_cmd =>
|
||||||
[ 'pg_dumpall', '-f', "$tempdir/pg_dumpall_globals.sql", '-g', ], },
|
[ 'pg_dumpall', '-v', '-f', "$tempdir/pg_dumpall_globals.sql", '-g', ], },
|
||||||
pg_dumpall_globals_clean => {
|
pg_dumpall_globals_clean => {
|
||||||
dump_cmd => [
|
dump_cmd => [
|
||||||
'pg_dumpall', '-f', "$tempdir/pg_dumpall_globals_clean.sql",
|
'pg_dumpall', '-f', "$tempdir/pg_dumpall_globals_clean.sql",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user