From e9a8d6d08265888bfd7534884c5d3207610559d6 Mon Sep 17 00:00:00 2001 From: Lee Dong Wook Date: Tue, 5 Jul 2022 18:31:26 +0900 Subject: [PATCH] add test for psql command with paramenter. - \help with parameter - \e - \encoding --- src/bin/psql/t/001_basic.pl | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/bin/psql/t/001_basic.pl b/src/bin/psql/t/001_basic.pl index 57486ceffdb7..d2ba512867b5 100644 --- a/src/bin/psql/t/001_basic.pl +++ b/src/bin/psql/t/001_basic.pl @@ -70,7 +70,39 @@ sub psql_fails_like psql_like($node, '\copyright', qr/Copyright/, '\copyright'); psql_like($node, '\help', qr/ALTER/, '\help without arguments'); -psql_like($node, '\help SELECT', qr/SELECT/, '\help with argument'); + +# ready \help with arguments +my $help_str = $node->safe_psql('postgres', '\help'); +my @help_commands = split('\n', $help_str); +shift @help_commands; + +map { s/^\s+|\s+$//g; } @help_commands; + +my @result; +foreach (@help_commands) { + my @commands = (substr($_, 0, 33), substr($_, 33)); + push @result, @commands; +} + +s{^\s+|\s+$}{}g foreach @result; + +# \help with arguments +foreach my $args (@result) { + psql_like($node, "\\help $args", qr/$args/, "\\help with $args arguments"); +} + +# test \e +$ENV{'PSQL_EDITOR'} = ($PostgreSQL::Test::Utils::windows_os) ? "type" : "/bin/cat"; + +# create some junk files for \e testing. +$node->safe_psql('postgres', + "\\o e.out\n" + . "SELECT 1;\n"); + +psql_like($node, "\\e e.out", qr/1/, "test \e"); + +# test \encoding +psql_like($node, "\\encoding", qr/UTF8/, "test \encoding"); # Test clean handling of unsupported replication command responses psql_fails_like(