|
4 | 4 | use Config;
|
5 | 5 | use PostgresNode;
|
6 | 6 | use TestLib;
|
7 |
| -use Test::More tests => 42; |
| 7 | +use Test::More tests => 70; |
8 | 8 |
|
9 | 9 | my $tempdir = TestLib::tempdir;
|
10 | 10 | my $tempdir_short = TestLib::tempdir_short;
|
|
28 | 28 | # Test various invalid options and disallowed combinations
|
29 | 29 | # Doesn't require a PG instance to be set up, so do this first.
|
30 | 30 |
|
31 |
| -command_exit_is([ 'pg_dump', 'qqq', 'abc' ], |
32 |
| - 1, 'pg_dump: too many command-line arguments (first is "asd")'); |
| 31 | +command_fails_like( |
| 32 | + [ 'pg_dump', 'qqq', 'abc' ], |
| 33 | + qr/\Qpg_dump: too many command-line arguments (first is "abc")\E/, |
| 34 | + 'pg_dump: too many command-line arguments (first is "asd")'); |
33 | 35 |
|
34 |
| -command_exit_is([ 'pg_restore', 'qqq', 'abc' ], |
35 |
| - 1, 'pg_restore too many command-line arguments (first is "asd")'); |
| 36 | +command_fails_like( |
| 37 | + [ 'pg_restore', 'qqq', 'abc' ], |
| 38 | + qr/\Qpg_restore: too many command-line arguments (first is "abc")\E/, |
| 39 | + 'pg_restore too many command-line arguments (first is "abc")'); |
36 | 40 |
|
37 |
| -command_exit_is([ 'pg_dumpall', 'qqq', 'abc' ], |
38 |
| - 1, 'pg_dumpall: too many command-line arguments (first is "qqq")'); |
| 41 | +command_fails_like( |
| 42 | + [ 'pg_dumpall', 'qqq', 'abc' ], |
| 43 | + qr/\Qpg_dumpall: too many command-line arguments (first is "qqq")\E/, |
| 44 | + 'pg_dumpall: too many command-line arguments (first is "qqq")'); |
39 | 45 |
|
40 |
| -command_exit_is( |
| 46 | +command_fails_like( |
41 | 47 | [ 'pg_dump', '-s', '-a' ],
|
42 |
| - 1, |
| 48 | +qr/\Qpg_dump: options -s\/--schema-only and -a\/--data-only cannot be used together\E/, |
43 | 49 | 'pg_dump: options -s/--schema-only and -a/--data-only cannot be used together'
|
44 | 50 | );
|
45 | 51 |
|
46 |
| -command_exit_is( |
| 52 | +command_fails_like( |
47 | 53 | [ 'pg_restore', '-s', '-a' ],
|
48 |
| - 1, |
| 54 | +qr/\Qpg_restore: options -s\/--schema-only and -a\/--data-only cannot be used together\E/, |
49 | 55 | 'pg_restore: options -s/--schema-only and -a/--data-only cannot be used together'
|
50 | 56 | );
|
51 | 57 |
|
52 |
| -command_exit_is([ 'pg_restore', '-d', 'xxx', '-f', 'xxx' ], |
53 |
| - 1, |
| 58 | +command_fails_like( |
| 59 | + [ 'pg_restore', '-d', 'xxx', '-f', 'xxx' ], |
| 60 | +qr/\Qpg_restore: options -d\/--dbname and -f\/--file cannot be used together\E/, |
54 | 61 | 'pg_restore: options -d/--dbname and -f/--file cannot be used together');
|
55 | 62 |
|
56 |
| -command_exit_is( |
| 63 | +command_fails_like( |
57 | 64 | [ 'pg_dump', '-c', '-a' ],
|
58 |
| - 1, |
| 65 | +qr/\Qpg_dump: options -c\/--clean and -a\/--data-only cannot be used together\E/, |
59 | 66 | 'pg_dump: options -c/--clean and -a/--data-only cannot be used together');
|
60 | 67 |
|
61 |
| -command_exit_is( |
| 68 | +command_fails_like( |
62 | 69 | [ 'pg_restore', '-c', '-a' ],
|
63 |
| - 1, |
| 70 | +qr/\Qpg_restore: options -c\/--clean and -a\/--data-only cannot be used together\E/, |
64 | 71 | 'pg_restore: options -c/--clean and -a/--data-only cannot be used together');
|
65 | 72 |
|
66 |
| -command_exit_is( |
| 73 | +command_fails_like( |
67 | 74 | [ 'pg_dump', '--inserts', '-o' ],
|
68 |
| - 1, |
| 75 | +qr/\Qpg_dump: options --inserts\/--column-inserts and -o\/--oids cannot be used together\E/, |
69 | 76 | 'pg_dump: options --inserts/--column-inserts and -o/--oids cannot be used together'
|
70 | 77 | );
|
71 | 78 |
|
72 |
| -command_exit_is([ 'pg_dump', '--if-exists' ], |
73 |
| - 1, 'pg_dump: option --if-exists requires option -c/--clean'); |
74 |
| - |
75 |
| -command_exit_is([ 'pg_dump', '-j' ], |
76 |
| - 1, 'pg_dump: option requires an argument -- \'j\''); |
77 |
| - |
78 |
| -command_exit_is([ 'pg_dump', '-j3' ], |
79 |
| - 1, 'pg_dump: parallel backup only supported by the directory format'); |
80 |
| - |
81 |
| -command_exit_is( |
| 79 | +command_fails_like( |
| 80 | + [ 'pg_dump', '--if-exists' ], |
| 81 | + qr/\Qpg_dump: option --if-exists requires option -c\/--clean\E/, |
| 82 | + 'pg_dump: option --if-exists requires option -c/--clean'); |
| 83 | + |
| 84 | +command_fails_like( |
| 85 | + [ 'pg_dump', '-j' ], |
| 86 | + qr/\Qpg_dump: option requires an argument -- 'j'\E/, |
| 87 | + 'pg_dump: option requires an argument -- \'j\''); |
| 88 | + |
| 89 | +command_fails_like( |
| 90 | + [ 'pg_dump', '-j3' ], |
| 91 | + qr/\Qpg_dump: parallel backup only supported by the directory format\E/, |
| 92 | + 'pg_dump: parallel backup only supported by the directory format'); |
| 93 | + |
| 94 | +command_fails_like( |
| 95 | + [ 'pg_dump', '-j', '-1' ], |
| 96 | + qr/\Qpg_dump: invalid number of parallel jobs\E/, |
| 97 | + 'pg_dump: invalid number of parallel jobs'); |
| 98 | + |
| 99 | +command_fails_like( |
| 100 | + [ 'pg_dump', '-F', 'garbage' ], |
| 101 | + qr/\Qpg_dump: invalid output format\E/, |
| 102 | + 'pg_dump: invalid output format'); |
| 103 | + |
| 104 | +command_fails_like( |
| 105 | + [ 'pg_restore', '-j', '-1' ], |
| 106 | + qr/\Qpg_restore: invalid number of parallel jobs\E/, |
| 107 | + 'pg_restore: invalid number of parallel jobs'); |
| 108 | + |
| 109 | +command_fails_like( |
82 | 110 | [ 'pg_restore', '--single-transaction', '-j3' ],
|
83 |
| - 1, |
| 111 | +qr/\Qpg_restore: cannot specify both --single-transaction and multiple jobs\E/, |
84 | 112 | 'pg_restore: cannot specify both --single-transaction and multiple jobs');
|
85 | 113 |
|
86 |
| -command_exit_is([ 'pg_restore', '--if-exists' ], |
87 |
| - 1, 'pg_restore: option --if-exists requires option -c/--clean'); |
| 114 | +command_fails_like( |
| 115 | + [ 'pg_dump', '-Z', '-1' ], |
| 116 | + qr/\Qpg_dump: compression level must be in range 0..9\E/, |
| 117 | + 'pg_dump: compression level must be in range 0..9'); |
| 118 | + |
| 119 | +command_fails_like( |
| 120 | + [ 'pg_restore', '--if-exists' ], |
| 121 | + qr/\Qpg_restore: option --if-exists requires option -c\/--clean\E/, |
| 122 | + 'pg_restore: option --if-exists requires option -c/--clean'); |
| 123 | + |
| 124 | +command_fails_like( |
| 125 | + [ 'pg_restore', '-F', 'garbage' ], |
| 126 | + qr/\Qpg_restore: unrecognized archive format "garbage";\E/, |
| 127 | + 'pg_dump: unrecognized archive format'); |
88 | 128 |
|
89 | 129 | # pg_dumpall command-line argument checks
|
90 |
| -command_exit_is( |
| 130 | +command_fails_like( |
91 | 131 | [ 'pg_dumpall', '-g', '-r' ],
|
92 |
| - 1, |
93 |
| -'pg_restore: options -g/--globals-only and -r/--roles-only cannot be used together' |
| 132 | +qr/\Qpg_dumpall: options -g\/--globals-only and -r\/--roles-only cannot be used together\E/, |
| 133 | +'pg_dumpall: options -g/--globals-only and -r/--roles-only cannot be used together' |
94 | 134 | );
|
95 | 135 |
|
96 |
| -command_exit_is( |
| 136 | +command_fails_like( |
97 | 137 | [ 'pg_dumpall', '-g', '-t' ],
|
98 |
| - 1, |
99 |
| -'pg_restore: options -g/--globals-only and -t/--tablespaces-only cannot be used together' |
| 138 | +qr/\Qpg_dumpall: options -g\/--globals-only and -t\/--tablespaces-only cannot be used together\E/, |
| 139 | +'pg_dumpall: options -g/--globals-only and -t/--tablespaces-only cannot be used together' |
100 | 140 | );
|
101 | 141 |
|
102 |
| -command_exit_is( |
| 142 | +command_fails_like( |
103 | 143 | [ 'pg_dumpall', '-r', '-t' ],
|
104 |
| - 1, |
105 |
| -'pg_restore: options -r/--roles-only and -t/--tablespaces-only cannot be used together' |
| 144 | +qr/\Qpg_dumpall: options -r\/--roles-only and -t\/--tablespaces-only cannot be used together\E/, |
| 145 | +'pg_dumpall: options -r/--roles-only and -t/--tablespaces-only cannot be used together' |
106 | 146 | );
|
107 | 147 |
|
108 |
| -command_exit_is([ 'pg_dumpall', '--if-exists' ], |
109 |
| - 1, 'pg_dumpall: option --if-exists requires option -c/--clean'); |
| 148 | +command_fails_like( |
| 149 | + [ 'pg_dumpall', '--if-exists' ], |
| 150 | + qr/\Qpg_dumpall: option --if-exists requires option -c\/--clean\E/, |
| 151 | + 'pg_dumpall: option --if-exists requires option -c/--clean'); |
0 commit comments