Debian Codegraph @

src/bin/scripts/t/101_vacuumdb_all.pl

raw
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 Test::More;
9
10 my $node = PostgreSQL::Test::Cluster->new('main');
11 $node->init;
12 $node->start;
13
14 $node->issues_sql_like(
15 [ 'vacuumdb', '--all' ],
16 qr/statement: VACUUM.*statement: VACUUM/s,
17 'vacuum all databases');
18
19 $node->safe_psql(
20 'postgres', q(
21 CREATE DATABASE regression_invalid;
22 UPDATE pg_database SET datconnlimit = -2 WHERE datname = 'regression_invalid';
23 ));
24 $node->command_ok([ 'vacuumdb', '--all' ],
25 'invalid database not targeted by vacuumdb -a');
26
27 # Doesn't quite belong here, but don't want to waste time by creating an
28 # invalid database in 010_vacuumdb.pl as well.
29 $node->command_fails_like(
30 [ 'vacuumdb', '--dbname' => 'regression_invalid' ],
31 qr/FATAL: cannot connect to invalid database "regression_invalid"/,
32 'vacuumdb cannot target invalid database');
33
34 done_testing();