Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c0280bc

Browse files
committed
psql: More tests
Add some basic tests for command-line option handling and help output, similar to what we have for other command-line programs. This also creates a place to put some more one-off test cases later. Discussion: https://www.postgresql.org/message-id/2570e2ae-fa0f-aac9-f72f-bb59a9983a20@enterprisedb.com
1 parent f9c4cb6 commit c0280bc

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

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

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
# Copyright (c) 2021, PostgreSQL Global Development Group
3+
4+
use strict;
5+
use warnings;
6+
7+
use PostgresNode;
8+
use TestLib;
9+
use Test::More tests => 23;
10+
11+
program_help_ok('psql');
12+
program_version_ok('psql');
13+
program_options_handling_ok('psql');
14+
15+
my ($stdout, $stderr);
16+
my $result;
17+
18+
# test --help=foo, analogous to program_help_ok()
19+
foreach my $arg (qw(commands variables))
20+
{
21+
$result = IPC::Run::run [ 'psql', "--help=$arg" ], '>', \$stdout, '2>', \$stderr;
22+
ok($result, "psql --help=$arg exit code 0");
23+
isnt($stdout, '', "psql --help=$arg goes to stdout");
24+
is($stderr, '', "psql --help=$arg nothing to stderr");
25+
}
26+
27+
my $node = PostgresNode->new('main');
28+
$node->init;
29+
$node->start;
30+
31+
$node->command_like([ 'psql', '-c', '\copyright' ], qr/Copyright/, '\copyright');
32+
$node->command_like([ 'psql', '-c', '\help' ], qr/ALTER/, '\help without arguments');
33+
$node->command_like([ 'psql', '-c', '\help SELECT' ], qr/SELECT/, '\help');

0 commit comments

Comments
 (0)