Skip to content

Commit 9028cce

Browse files
committed
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
1 parent a33e17f commit 9028cce

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

src/bin/psql/t/001_basic.pl

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ sub psql_fails_like
6060
}
6161

6262
my $node = PostgreSQL::Test::Cluster->new('main');
63-
$node->init;
63+
$node->init(extra => [ '--locale=C', '--encoding=UTF8' ]);
6464
$node->append_conf(
6565
'postgresql.conf', q{
6666
wal_level = 'logical'
@@ -80,4 +80,39 @@ sub psql_fails_like
8080
qr/unexpected PQresultStatus: 8$/,
8181
'handling of unexpected PQresultStatus');
8282

83+
# test \timing
84+
psql_like(
85+
$node,
86+
'\timing on
87+
SELECT 1',
88+
qr/^1$
89+
^Time: \d+.\d\d\d ms/m,
90+
'\timing');
91+
92+
# test that ENCODING variable is set and that it is updated when
93+
# client encoding is changed
94+
psql_like(
95+
$node,
96+
'\echo :ENCODING
97+
set client_encoding = LATIN1;
98+
\echo :ENCODING',
99+
qr/^UTF8$
100+
^LATIN1$/m,
101+
'ENCODING variable is set and updated');
102+
103+
# test LISTEN/NOTIFY
104+
psql_like(
105+
$node,
106+
'LISTEN foo;
107+
NOTIFY foo;',
108+
qr/^Asynchronous notification "foo" received from server process with PID \d+\.$/,
109+
'notification');
110+
111+
psql_like(
112+
$node,
113+
"LISTEN foo;
114+
NOTIFY foo, 'bar';",
115+
qr/^Asynchronous notification "foo" with payload "bar" received from server process with PID \d+\.$/,
116+
'notification with payload');
117+
83118
done_testing();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy