| 1 |
|
| 2 |
# Copyright (c) 2021-2025, PostgreSQL Global Development Group |
| 3 |
|
| 4 |
use strict; |
| 5 |
use warnings FATAL => 'all'; |
| 6 |
|
| 7 |
use PostgreSQL::Test::Cluster; |
| 8 |
use PostgreSQL::Test::Utils; |
| 9 |
use Test::More; |
| 10 |
|
| 11 |
program_help_ok('clusterdb'); |
| 12 |
program_version_ok('clusterdb'); |
| 13 |
program_options_handling_ok('clusterdb'); |
| 14 |
|
| 15 |
my $node = PostgreSQL::Test::Cluster->new('main'); |
| 16 |
$node->init; |
| 17 |
$node->start; |
| 18 |
|
| 19 |
$node->issues_sql_like( |
| 20 |
['clusterdb'], |
| 21 |
qr/statement: CLUSTER;/, |
| 22 |
'SQL CLUSTER run'); |
| 23 |
|
| 24 |
$node->command_fails_like( |
| 25 |
[ 'clusterdb', '--table' => 'nonexistent' ], |
| 26 |
qr/relation "nonexistent" does not exist/, |
| 27 |
'fails with nonexistent table'); |
| 28 |
|
| 29 |
$node->safe_psql('postgres', |
| 30 |
'CREATE TABLE test1 (a int); CREATE INDEX test1x ON test1 (a); CLUSTER test1 USING test1x' |
| 31 |
); |
| 32 |
$node->issues_sql_like( |
| 33 |
[ 'clusterdb', '--table' => 'test1' ], |
| 34 |
qr/statement: CLUSTER public\.test1;/, |
| 35 |
'cluster specific table'); |
| 36 |
|
| 37 |
$node->command_ok([qw(clusterdb --echo --verbose dbname=template1)], |
| 38 |
'clusterdb with connection string'); |
| 39 |
|
| 40 |
done_testing(); |