You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-06-14 23:44:58 +02:00
Refactor protocol param generation into a new function.
This allows the code to be tested more precisely and doesn't require executing a remote process.
This commit is contained in:
@ -23,6 +23,7 @@ use pgBackRest::Config::Config;
|
||||
use pgBackRest::Protocol::Helper;
|
||||
use pgBackRest::Protocol::Storage::Helper;
|
||||
use pgBackRest::Storage::Helper;
|
||||
use pgBackRest::Version;
|
||||
|
||||
use pgBackRestTest::Env::HostEnvTest;
|
||||
use pgBackRestTest::Common::ExecuteTest;
|
||||
@ -50,8 +51,6 @@ sub initTest
|
||||
|
||||
# Create archive info
|
||||
storageTest()->pathCreate($self->{strArchivePath}, {bIgnoreExists => true, bCreateParent => true});
|
||||
|
||||
$self->initOption();
|
||||
}
|
||||
|
||||
####################################################################################################################################
|
||||
@ -61,6 +60,8 @@ sub initOption
|
||||
{
|
||||
my $self = shift;
|
||||
|
||||
$self->configTestClear();
|
||||
|
||||
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
|
||||
$self->optionTestSet(CFGOPT_DB_PATH, $self->{strDbPath});
|
||||
$self->optionTestSet(CFGOPT_REPO_PATH, $self->{strRepoPath});
|
||||
@ -79,11 +80,28 @@ sub run
|
||||
{
|
||||
my $self = shift;
|
||||
|
||||
my $oOption = $self->initOption();
|
||||
################################################################################################################################
|
||||
if ($self->begin('protocolParam()'))
|
||||
{
|
||||
$self->optionTestSet(CFGOPT_STANZA, $self->stanza());
|
||||
$self->optionTestSet(cfgOptionIdFromIndex(CFGOPT_DB_HOST, 1), 'db-host-1');
|
||||
$self->optionTestSet(cfgOptionIdFromIndex(CFGOPT_DB_PATH, 1), '/db1');
|
||||
$self->optionTestSet(cfgOptionIdFromIndex(CFGOPT_DB_PORT, 1), '1111');
|
||||
$self->optionTestSet(cfgOptionIdFromIndex(CFGOPT_DB_CMD, 1), 'pgbackrest1');
|
||||
$self->configTestLoad(CFGCMD_BACKUP);
|
||||
|
||||
$self->testResult(
|
||||
sub {pgBackRest::Protocol::Helper::protocolParam(
|
||||
cfgCommandName(CFGCMD_BACKUP), CFGOPTVAL_REMOTE_TYPE_DB, 1)},
|
||||
'(db-host-1, postgres, [undef], pgbackrest1 --buffer-size=4194304 --command=backup --compress-level=6' .
|
||||
' --compress-level-network=3 --db1-path=/db1 --db1-port=1111 --protocol-timeout=1830 --stanza=db --type=db remote)',
|
||||
'more than one backup db host');
|
||||
}
|
||||
|
||||
################################################################################################################################
|
||||
if ($self->begin("Protocol::Helper"))
|
||||
{
|
||||
$self->initOption();
|
||||
$self->optionTestSet(CFGOPT_BACKUP_HOST, 'localhost');
|
||||
$self->optionTestSet(CFGOPT_BACKUP_USER, $self->pgUser());
|
||||
$self->configTestLoad(CFGCMD_ARCHIVE_PUSH);
|
||||
|
Reference in New Issue
Block a user