Skip to content

Commit 9b815a8

Browse files
committed
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 6bd356c, 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.
1 parent de5fed0 commit 9b815a8

File tree

2 files changed

+64
-5
lines changed

2 files changed

+64
-5
lines changed

src/bin/pg_dump/t/001_basic.pl

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use Config;
55
use PostgresNode;
66
use TestLib;
7-
use Test::More tests => 15;
7+
use Test::More tests => 42;
88

99
my $tempdir = TestLib::tempdir;
1010
my $tempdir_short = TestLib::tempdir_short;
@@ -16,24 +16,55 @@
1616
program_version_ok('pg_dump');
1717
program_options_handling_ok('pg_dump');
1818

19+
program_help_ok('pg_restore');
20+
program_version_ok('pg_restore');
21+
program_options_handling_ok('pg_restore');
22+
23+
program_help_ok('pg_dumpall');
24+
program_version_ok('pg_dumpall');
25+
program_options_handling_ok('pg_dumpall');
26+
1927
#########################################
2028
# Test various invalid options and disallowed combinations
2129
# Doesn't require a PG instance to be set up, so do this first.
2230

2331
command_exit_is([ 'pg_dump', 'qqq', 'abc' ],
2432
1, 'pg_dump: too many command-line arguments (first is "asd")');
2533

34+
command_exit_is([ 'pg_restore', 'qqq', 'abc' ],
35+
1, 'pg_restore too many command-line arguments (first is "asd")');
36+
37+
command_exit_is([ 'pg_dumpall', 'qqq', 'abc' ],
38+
1, 'pg_dumpall: too many command-line arguments (first is "qqq")');
39+
2640
command_exit_is(
2741
[ 'pg_dump', '-s', '-a' ],
2842
1,
2943
'pg_dump: options -s/--schema-only and -a/--data-only cannot be used together'
3044
);
3145

46+
command_exit_is(
47+
[ 'pg_restore', '-s', '-a' ],
48+
1,
49+
'pg_restore: options -s/--schema-only and -a/--data-only cannot be used together'
50+
);
51+
52+
command_exit_is(
53+
[ 'pg_restore', '-d', 'xxx', '-f', 'xxx' ],
54+
1,
55+
'pg_restore: options -d/--dbname and -f/--file cannot be used together'
56+
);
57+
3258
command_exit_is(
3359
[ 'pg_dump', '-c', '-a' ],
3460
1,
3561
'pg_dump: options -c/--clean and -a/--data-only cannot be used together');
3662

63+
command_exit_is(
64+
[ 'pg_restore', '-c', '-a' ],
65+
1,
66+
'pg_restore: options -c/--clean and -a/--data-only cannot be used together');
67+
3768
command_exit_is(
3869
[ 'pg_dump', '--inserts', '-o' ],
3970
1,
@@ -48,3 +79,31 @@
4879

4980
command_exit_is([ 'pg_dump', '-j3' ],
5081
1, 'pg_dump: parallel backup only supported by the directory format');
82+
83+
command_exit_is([ 'pg_restore', '--single-transaction', '-j3' ],
84+
1, 'pg_restore: cannot specify both --single-transaction and multiple jobs');
85+
86+
command_exit_is([ 'pg_restore', '--if-exists' ],
87+
1, 'pg_restore: option --if-exists requires option -c/--clean');
88+
89+
# pg_dumpall command-line argument checks
90+
command_exit_is(
91+
[ 'pg_dumpall', '-g', '-r' ],
92+
1,
93+
'pg_restore: options -g/--globals-only and -r/--roles-only cannot be used together'
94+
);
95+
96+
command_exit_is(
97+
[ 'pg_dumpall', '-g', '-t' ],
98+
1,
99+
'pg_restore: options -g/--globals-only and -t/--tablespaces-only cannot be used together'
100+
);
101+
102+
command_exit_is(
103+
[ 'pg_dumpall', '-r', '-t' ],
104+
1,
105+
'pg_restore: options -r/--roles-only and -t/--tablespaces-only cannot be used together'
106+
);
107+
108+
command_exit_is([ 'pg_dumpall', '--if-exists' ],
109+
1, 'pg_dumpall: option --if-exists requires option -c/--clean');

src/bin/pg_dump/t/002_pg_dump.pl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
"$tempdir/defaults_custom_format.dump", 'postgres', ],
8989
restore_cmd => [
9090
'pg_restore',
91-
'-f',
91+
'-Fc', '-f',
9292
"$tempdir/defaults_custom_format.sql",
9393
"$tempdir/defaults_custom_format.dump", ], },
9494
defaults_dir_format => {
@@ -98,7 +98,7 @@
9898
'postgres', ],
9999
restore_cmd => [
100100
'pg_restore',
101-
'-f',
101+
'-Fd', '-f',
102102
"$tempdir/defaults_dir_format.sql",
103103
"$tempdir/defaults_dir_format", ], },
104104
defaults_parallel => {
@@ -117,7 +117,7 @@
117117
'postgres', ],
118118
restore_cmd => [
119119
'pg_restore',
120-
'-f',
120+
'-Ft', '-f',
121121
"$tempdir/defaults_tar_format.sql",
122122
"$tempdir/defaults_tar_format.tar", ], },
123123
exclude_dump_test_schema => {
@@ -136,7 +136,7 @@
136136
'--exclude-table-data=dump_test.test_table', 'postgres', ], },
137137
pg_dumpall_globals => {
138138
dump_cmd =>
139-
[ 'pg_dumpall', '-f', "$tempdir/pg_dumpall_globals.sql", '-g', ], },
139+
[ 'pg_dumpall', '-v', '-f', "$tempdir/pg_dumpall_globals.sql", '-g', ], },
140140
pg_dumpall_globals_clean => {
141141
dump_cmd => [
142142
'pg_dumpall', '-f', "$tempdir/pg_dumpall_globals_clean.sql",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy