| 1 |
|
| 2 |
# Copyright (c) 2021-2025, PostgreSQL Global Development Group |
| 3 |
|
| 4 |
use strict; |
| 5 |
use warnings FATAL => 'all'; |
| 6 |
use PostgreSQL::Test::Utils; |
| 7 |
use Test::More; |
| 8 |
|
| 9 |
my $tempdir = PostgreSQL::Test::Utils::tempdir; |
| 10 |
|
| 11 |
program_help_ok('pg_verifybackup'); |
| 12 |
program_version_ok('pg_verifybackup'); |
| 13 |
program_options_handling_ok('pg_verifybackup'); |
| 14 |
|
| 15 |
command_fails_like( |
| 16 |
['pg_verifybackup'], |
| 17 |
qr/no backup directory specified/, |
| 18 |
'target directory must be specified'); |
| 19 |
command_fails_like( |
| 20 |
[ 'pg_verifybackup', $tempdir ], |
| 21 |
qr/could not open file.*\/backup_manifest\"/, |
| 22 |
'pg_verifybackup requires a manifest'); |
| 23 |
command_fails_like( |
| 24 |
[ 'pg_verifybackup', $tempdir, $tempdir ], |
| 25 |
qr/too many command-line arguments/, |
| 26 |
'multiple target directories not allowed'); |
| 27 |
|
| 28 |
# create fake manifest file |
| 29 |
open(my $fh, '>', "$tempdir/backup_manifest") || die "open: $!"; |
| 30 |
close($fh); |
| 31 |
|
| 32 |
# but then try to use an alternate, nonexisting manifest |
| 33 |
command_fails_like( |
| 34 |
[ |
| 35 |
'pg_verifybackup', |
| 36 |
'--manifest-path' => "$tempdir/not_the_manifest", |
| 37 |
$tempdir, |
| 38 |
], |
| 39 |
qr/could not open file.*\/not_the_manifest\"/, |
| 40 |
'pg_verifybackup respects -m flag'); |
| 41 |
|
| 42 |
done_testing(); |