1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-05 00:28:52 +02:00

Use harnessCfgLoadRaw() in command/help unit test.

This correctly set defaults from cfgLoadUpdateOption(), e.g. repo-host-cmd.
This commit is contained in:
David Steele
2020-10-19 16:27:52 -04:00
parent 303b9b17e7
commit 996387ea93

View File

@ -6,6 +6,8 @@ Test Help Command
#include "storage/storage.h"
#include "version.h"
#include "common/harnessConfig.h"
/***********************************************************************************************************************************
Test Run
***********************************************************************************************************************************/
@ -84,13 +86,13 @@ testRun(void)
// -------------------------------------------------------------------------------------------------------------------------
argList = strLstNew();
strLstAddZ(argList, "/path/to/pgbackrest");
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "help from empty command line");
TEST_RESULT_VOID(harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help from empty command line");
TEST_RESULT_STR_Z(helpRender(), generalHelp, " check text");
argList = strLstNew();
strLstAddZ(argList, "/path/to/pgbackrest");
strLstAddZ(argList, "help");
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "help from help command");
TEST_RESULT_VOID(harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help from help command");
TEST_RESULT_STR_Z(helpRender(), generalHelp, " check text");
// -------------------------------------------------------------------------------------------------------------------------
@ -107,7 +109,7 @@ testRun(void)
strLstAddZ(argList, "/path/to/pgbackrest");
strLstAddZ(argList, "help");
strLstAddZ(argList, "version");
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "help for version command");
TEST_RESULT_VOID(harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help for version command");
TEST_RESULT_STR_Z(helpRender(), commandHelp, " check text");
// This test is broken up into multiple strings because C99 does not require compilers to support const strings > 4095 bytes
@ -203,6 +205,7 @@ testRun(void)
" --repo-host repository host when operating remotely via\n"
" SSH [current=backup.example.net]\n"
" --repo-host-cmd pgBackRest exe path on the repository host\n"
" [default=/path/to/pgbackrest]\n"
" --repo-host-config pgBackRest repository host configuration\n"
" file\n"
" [default=/etc/pgbackrest/pgbackrest.conf]\n"
@ -250,7 +253,7 @@ testRun(void)
strLstAddZ(argList, "--link-map=/link2=/dest2");
strLstAddZ(argList, "--db-include=db1");
strLstAddZ(argList, "--db-include=db2");
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "help for restore command");
TEST_RESULT_VOID(harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help for restore command");
unsetenv("PGBACKREST_REPO1_CIPHER_PASS");
TEST_RESULT_STR_Z(helpRender(), commandHelp, " check text");
@ -261,7 +264,7 @@ testRun(void)
strLstAddZ(argList, "archive-push");
strLstAddZ(argList, "buffer-size");
strLstAddZ(argList, "buffer-size");
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "parse too many options");
TEST_RESULT_VOID(harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "parse too many options");
TEST_ERROR(helpRender(), ParamInvalidError, "only one option allowed for option help");
argList = strLstNew();
@ -269,7 +272,7 @@ testRun(void)
strLstAddZ(argList, "help");
strLstAddZ(argList, "archive-push");
strLstAddZ(argList, BOGUS_STR);
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "parse bogus option");
TEST_RESULT_VOID(harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "parse bogus option");
TEST_ERROR(helpRender(), OptionInvalidError, "option 'BOGUS' is not valid for command 'archive-push'");
// -------------------------------------------------------------------------------------------------------------------------
@ -296,12 +299,12 @@ testRun(void)
strLstAddZ(argList, "archive-push");
strLstAddZ(argList, "buffer-size");
TEST_RESULT_VOID(
configParse(strLstSize(argList), strLstPtr(argList), false), "help for archive-push command, buffer-size option");
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help for archive-push command, buffer-size option");
TEST_RESULT_STR(helpRender(), strNewFmt("%s\ndefault: 1048576\n", optionHelp), " check text");
strLstAddZ(argList, "--buffer-size=32768");
TEST_RESULT_VOID(
configParse(strLstSize(argList), strLstPtr(argList), false), "help for archive-push command, buffer-size option");
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help for archive-push command, buffer-size option");
TEST_RESULT_STR(helpRender(), strNewFmt("%s\ncurrent: 32768\ndefault: 1048576\n", optionHelp), " check text");
// -------------------------------------------------------------------------------------------------------------------------
@ -319,13 +322,13 @@ testRun(void)
strLstAddZ(argList, "archive-push");
strLstAddZ(argList, "repo1-s3-host");
TEST_RESULT_VOID(
configParse(strLstSize(argList), strLstPtr(argList), false), "help for archive-push command, repo1-s3-host option");
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help for archive-push command, repo1-s3-host option");
TEST_RESULT_STR_Z(helpRender(), optionHelp, " check text");
strLstAddZ(argList, "--repo1-type=s3");
strLstAddZ(argList, "--repo1-s3-host=s3-host");
TEST_RESULT_VOID(
configParse(strLstSize(argList), strLstPtr(argList), false), "help for archive-push command, repo1-s3-host option");
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help for archive-push command, repo1-s3-host option");
TEST_RESULT_STR(helpRender(), strNewFmt("%s\ncurrent: s3-host\n", optionHelp), " check text");
// -------------------------------------------------------------------------------------------------------------------------
@ -347,7 +350,7 @@ testRun(void)
strLstAddZ(argList, "archive-push");
strLstAddZ(argList, "repo-cipher-pass");
TEST_RESULT_VOID(
configParse(strLstSize(argList), strLstPtr(argList), false), "help for archive-push command, repo1-s3-host option");
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help for archive-push command, repo1-s3-host option");
unsetenv("PGBACKREST_REPO1_CIPHER_PASS");
TEST_RESULT_STR_Z(helpRender(), optionHelp, " check text");
@ -373,7 +376,7 @@ testRun(void)
strLstAddZ(argList, "backup");
strLstAddZ(argList, "repo-hardlink");
TEST_RESULT_VOID(
configParse(strLstSize(argList), strLstPtr(argList), false), "help for backup command, repo-hardlink option");
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help for backup command, repo-hardlink option");
TEST_RESULT_STR_Z(helpRender(), optionHelp, " check text");
// Check admonition
@ -409,7 +412,7 @@ testRun(void)
strLstAddZ(argList, "backup");
strLstAddZ(argList, "repo-retention-archive");
TEST_RESULT_VOID(
configParse(strLstSize(argList), strLstPtr(argList), false), "help for backup command, repo-retention-archive option");
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "help for backup command, repo-retention-archive option");
TEST_RESULT_STR_Z(helpRender(), optionHelp, " check admonition text");
}
@ -418,7 +421,7 @@ testRun(void)
{
StringList *argList = strLstNew();
strLstAddZ(argList, "/path/to/pgbackrest");
TEST_RESULT_VOID(configParse(strLstSize(argList), strLstPtr(argList), false), "parse help from empty command line");
TEST_RESULT_VOID(harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList)), "parse help from empty command line");
// Redirect stdout to a file
int stdoutSave = dup(STDOUT_FILENO);