Add error pattern checks for some TAP tests for non-existing objects
authorMichael Paquier <[email protected]>
Thu, 23 Jan 2025 07:03:48 +0000 (16:03 +0900)
committerMichael Paquier <[email protected]>
Thu, 23 Jan 2025 07:03:48 +0000 (16:03 +0900)
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/[email protected]

src/bin/pg_amcheck/t/002_nonesuch.pl
src/bin/scripts/t/010_clusterdb.pl
src/bin/scripts/t/050_dropdb.pl
src/bin/scripts/t/070_dropuser.pl

index f6011d000b74534ff04e9c4e77103e241e2154e0..2697f1c1b1a6b0f85ea98162ca74a91b0567a4c1 100644 (file)
@@ -85,7 +85,10 @@ $node->command_checks_all(
 # Failing to connect to the initial database due to bad username is an error.
 $node->command_checks_all(
    [ 'pg_amcheck', '--username' => 'no_such_user', 'postgres' ],
-   1, [qr/^$/], [], 'checking with a non-existent user');
+   1,
+   [qr/^$/],
+   [qr/role "no_such_user" does not exist/],
+   'checking with a non-existent user');
 
 #########################################
 # Test checking databases without amcheck installed
index a4e4d46857856f8c4081c697cc920e2c4a244b2e..65a32b6c4c52e9d2a24ca4cd328d74b509e834f6 100644 (file)
@@ -21,7 +21,9 @@ $node->issues_sql_like(
    qr/statement: CLUSTER;/,
    'SQL CLUSTER run');
 
-$node->command_fails([ 'clusterdb', '--table' => 'nonexistent' ],
+$node->command_fails_like(
+   [ 'clusterdb', '--table' => 'nonexistent' ],
+   qr/relation "nonexistent" does not exist/,
    'fails with nonexistent table');
 
 $node->safe_psql('postgres',
index 9db0345119f69eb0d76e55678bf0bf94a0d7ab67..d0bf4924ce48b9ccec9185e5830445404d19a7bd 100644 (file)
@@ -28,7 +28,9 @@ $node->issues_sql_like(
    qr/statement: DROP DATABASE foobar2 WITH \(FORCE\);/,
    'SQL DROP DATABASE (FORCE) run');
 
-$node->command_fails([ 'dropdb', 'nonexistent' ],
+$node->command_fails_like(
+   [ 'dropdb', 'nonexistent' ],
+   qr/database "nonexistent" does not exist/,
    'fails with nonexistent database');
 
 # check that invalid database can be dropped with dropdb
index 2c432fbdb63edae19a2bd9c4a6cd71ad0b8b059f..5f100978446b825524bd63ca83091d961ac2e9c9 100644 (file)
@@ -22,7 +22,9 @@ $node->issues_sql_like(
    qr/statement: DROP ROLE regress_foobar1/,
    'SQL DROP ROLE run');
 
-$node->command_fails([ 'dropuser', 'regress_nonexistent' ],
+$node->command_fails_like(
+   [ 'dropuser', 'regress_nonexistent' ],
+   qr/role "regress_nonexistent" does not exist/,
    'fails with nonexistent user');
 
 done_testing();