Skip to content

Commit eef4a33

Browse files
committed
Add error pattern checks for some TAP tests for non-existing objects
Some tests are updated to use command_fails_like(), gaining a check for the error output generated. The test changed in pg_amcheck has come up after noticing that an incorrect option name still made the test to pass, while the command failed. The three other tests changed in src/bin/scripts/ have been noticed by me, in passing. Author: Dagfinn Ilmari Mannsåker, Michael Paquier Discussion: https://postgr.es/m/87bjvy50cs.fsf@wibble.ilmari.org
1 parent 858b4db commit eef4a33

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

src/bin/pg_amcheck/t/002_nonesuch.pl

+4-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,10 @@
8585
# Failing to connect to the initial database due to bad username is an error.
8686
$node->command_checks_all(
8787
[ 'pg_amcheck', '--username' => 'no_such_user', 'postgres' ],
88-
1, [qr/^$/], [], 'checking with a non-existent user');
88+
1,
89+
[qr/^$/],
90+
[qr/role "no_such_user" does not exist/],
91+
'checking with a non-existent user');
8992

9093
#########################################
9194
# Test checking databases without amcheck installed

src/bin/scripts/t/010_clusterdb.pl

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
qr/statement: CLUSTER;/,
2222
'SQL CLUSTER run');
2323

24-
$node->command_fails([ 'clusterdb', '--table' => 'nonexistent' ],
24+
$node->command_fails_like(
25+
[ 'clusterdb', '--table' => 'nonexistent' ],
26+
qr/relation "nonexistent" does not exist/,
2527
'fails with nonexistent table');
2628

2729
$node->safe_psql('postgres',

src/bin/scripts/t/050_dropdb.pl

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
qr/statement: DROP DATABASE foobar2 WITH \(FORCE\);/,
2929
'SQL DROP DATABASE (FORCE) run');
3030

31-
$node->command_fails([ 'dropdb', 'nonexistent' ],
31+
$node->command_fails_like(
32+
[ 'dropdb', 'nonexistent' ],
33+
qr/database "nonexistent" does not exist/,
3234
'fails with nonexistent database');
3335

3436
# check that invalid database can be dropped with dropdb

src/bin/scripts/t/070_dropuser.pl

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
qr/statement: DROP ROLE regress_foobar1/,
2323
'SQL DROP ROLE run');
2424

25-
$node->command_fails([ 'dropuser', 'regress_nonexistent' ],
25+
$node->command_fails_like(
26+
[ 'dropuser', 'regress_nonexistent' ],
27+
qr/role "regress_nonexistent" does not exist/,
2628
'fails with nonexistent user');
2729

2830
done_testing();

0 commit comments

Comments
 (0)