aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2022-03-01 11:21:20 +0100
committerPeter Eisentraut <peter@eisentraut.org>2022-03-01 11:23:28 +0100
commit9028cce426ba6e08ee5ef8fcaedb2445e6c08c75 (patch)
tree3bfba8088cf6fe4fe093eccf626c26e069e79345 /src
parenta33e17f210547226ada52d2b8af851c3553bb4fa (diff)
downloadpostgresql-9028cce426ba6e08ee5ef8fcaedb2445e6c08c75.tar.gz
postgresql-9028cce426ba6e08ee5ef8fcaedb2445e6c08c75.zip
psql: Additional tests
Add a few TAP tests for things that happen while a user query is being sent: - \timing - client encoding handling - notifications Discussion: https://www.postgresql.org/message-id/3199e176-424e-1bef-f180-c1548466c2da@enterprisedb.com
Diffstat (limited to 'src')
-rw-r--r--src/bin/psql/t/001_basic.pl37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/bin/psql/t/001_basic.pl b/src/bin/psql/t/001_basic.pl
index f416e0ab5e8..44ecd05add6 100644
--- a/src/bin/psql/t/001_basic.pl
+++ b/src/bin/psql/t/001_basic.pl
@@ -60,7 +60,7 @@ foreach my $arg (qw(commands variables))
}
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 @@ 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();