diff options
Diffstat (limited to 'src/bin/pg_ctl/t/002_status.pl')
-rw-r--r-- | src/bin/pg_ctl/t/002_status.pl | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/bin/pg_ctl/t/002_status.pl b/src/bin/pg_ctl/t/002_status.pl new file mode 100644 index 0000000..ab26ee6 --- /dev/null +++ b/src/bin/pg_ctl/t/002_status.pl @@ -0,0 +1,29 @@ + +# Copyright (c) 2021-2022, PostgreSQL Global Development Group + +use strict; +use warnings; + +use PostgreSQL::Test::Cluster; +use PostgreSQL::Test::Utils; +use Test::More; + +my $tempdir = PostgreSQL::Test::Utils::tempdir; + +command_exit_is([ 'pg_ctl', 'status', '-D', "$tempdir/nonexistent" ], + 4, 'pg_ctl status with nonexistent directory'); + +my $node = PostgreSQL::Test::Cluster->new('main'); +$node->init; + +command_exit_is([ 'pg_ctl', 'status', '-D', $node->data_dir ], + 3, 'pg_ctl status with server not running'); + +system_or_bail 'pg_ctl', '-l', "$tempdir/logfile", '-D', + $node->data_dir, '-w', 'start'; +command_exit_is([ 'pg_ctl', 'status', '-D', $node->data_dir ], + 0, 'pg_ctl status with server running'); + +system_or_bail 'pg_ctl', 'stop', '-D', $node->data_dir; + +done_testing(); |