From 189e977e47c505230195551833e0a61ec71dced3 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 22 Feb 2022 14:20:05 +0100 Subject: [PATCH 2/2] psql: Additional tests Add a few TAP tests for things that happen while a user query is being sent: - \timing - client encoding handling - notifications --- src/bin/psql/t/001_basic.pl | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/bin/psql/t/001_basic.pl b/src/bin/psql/t/001_basic.pl index f416e0ab5e..44ecd05add 100644 --- a/src/bin/psql/t/001_basic.pl +++ b/src/bin/psql/t/001_basic.pl @@ -60,7 +60,7 @@ sub psql_fails_like } my $node = PostgreSQL::Test::Cluster->new('main'); -$node->init; +$node->init(extra => [ '--locale=C', '--encoding=UTF8' ]); $node->append_conf( 'postgresql.conf', q{ wal_level = 'logical' @@ -80,4 +80,39 @@ sub psql_fails_like qr/unexpected PQresultStatus: 8$/, 'handling of unexpected PQresultStatus'); +# test \timing +psql_like( + $node, + '\timing on +SELECT 1', + qr/^1$ +^Time: \d+.\d\d\d ms/m, + '\timing'); + +# test that ENCODING variable is set and that it is updated when +# client encoding is changed +psql_like( + $node, + '\echo :ENCODING +set client_encoding = LATIN1; +\echo :ENCODING', + qr/^UTF8$ +^LATIN1$/m, + 'ENCODING variable is set and updated'); + +# test LISTEN/NOTIFY +psql_like( + $node, + 'LISTEN foo; +NOTIFY foo;', + qr/^Asynchronous notification "foo" received from server process with PID \d+\.$/, + 'notification'); + +psql_like( + $node, + "LISTEN foo; +NOTIFY foo, 'bar';", + qr/^Asynchronous notification "foo" with payload "bar" received from server process with PID \d+\.$/, + 'notification with payload'); + done_testing(); -- 2.35.1