mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-14 10:13:05 +02:00
Add tests for InfoPg history fixes introduced in 070455ce
.
The existing tests were not adequate to ensure the history was being added in the correct order when some entries were loaded from a file and others added with infoPgAdd(). Contributed by Cynthia Shang.
This commit is contained in:
parent
070455ce44
commit
5590bfa84c
@ -17,7 +17,8 @@
|
||||
<release-development-list>
|
||||
<release-item>
|
||||
<release-item-contributor-list>
|
||||
<release-item-ideator id="cynthia.shang"/>
|
||||
<release-item-contributor id="cynthia.shang"/>
|
||||
<release-item-contributor id="david.steele"/>
|
||||
</release-item-contributor-list>
|
||||
|
||||
<p>Correct current history item in <code>InfoPg</code> to always be in position 0.</p>
|
||||
|
@ -107,7 +107,7 @@ Internal function to check if the information is valid or not
|
||||
static bool
|
||||
infoValidInternal(
|
||||
const Info *this, // Info object to validate
|
||||
bool ignoreError) // ignore errors found?
|
||||
bool ignoreError) // ignore errors found?
|
||||
{
|
||||
FUNCTION_TEST_BEGIN();
|
||||
FUNCTION_TEST_PARAM(INFO, this);
|
||||
|
@ -129,7 +129,7 @@ infoPgNew(const Storage *storage, const String *fileName, InfoPgType type)
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Add Postgres data to the history list and return the new currentIndex
|
||||
Add Postgres data to the history list at position 0 to ensure the latest history is always first in the list
|
||||
***********************************************************************************************************************************/
|
||||
void
|
||||
infoPgAdd(InfoPg *this, const InfoPgData *infoPgData)
|
||||
|
@ -85,32 +85,55 @@ testRun(void)
|
||||
|
||||
// Manifest info
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
content = strNew
|
||||
(
|
||||
"[backrest]\n"
|
||||
"backrest-checksum=\"62e4d16add4b111bed37c9e9ab0b6f60897e27da\"\n"
|
||||
"backrest-format=5\n"
|
||||
"backrest-version=\"2.04\"\n"
|
||||
"\n"
|
||||
"[db]\n"
|
||||
"db-catalog-version=201510051\n"
|
||||
"db-control-version=942\n"
|
||||
"db-id=2\n"
|
||||
"db-system-id=6365925855999999999\n"
|
||||
"db-version=\"9.5\"\n"
|
||||
"\n"
|
||||
"[db:history]\n"
|
||||
"1={\"db-catalog-version\":201409291,\"db-control-version\":942,\"db-system-id\":6569239123849665679,"
|
||||
"\"db-version\":\"9.4\"}\n"
|
||||
"2={\"db-catalog-version\":201510051,\"db-control-version\":942,\"db-system-id\":6365925855999999999,"
|
||||
"\"db-version\":\"9.5\"}\n"
|
||||
);
|
||||
|
||||
TEST_RESULT_VOID(storagePutNP(storageNewWriteNP(storageLocalWrite(), fileName), bufNewStr(content)), "put info to file");
|
||||
|
||||
TEST_ASSIGN(infoPg, infoPgNew(storageLocal(), fileName, infoPgManifest), "new infoPg manifest - load file");
|
||||
|
||||
TEST_RESULT_INT(lstSize(infoPg->history), 1, "history record added");
|
||||
TEST_RESULT_INT(lstSize(infoPg->history), 2, "history record added");
|
||||
|
||||
infoPgData = infoPgDataCurrent(infoPg);
|
||||
TEST_RESULT_INT(infoPgData.id, 1, " id set");
|
||||
TEST_RESULT_INT(infoPgData.version, PG_VERSION_94, " version set");
|
||||
TEST_RESULT_INT(infoPgData.systemId, 6569239123849665679, " system-id set");
|
||||
TEST_RESULT_INT(infoPgData.catalogVersion, 201409291, " catalog-version set");
|
||||
TEST_RESULT_INT(infoPgData.id, 2, " id set");
|
||||
TEST_RESULT_INT(infoPgData.version, PG_VERSION_95, " version set");
|
||||
TEST_RESULT_INT(infoPgData.systemId, 6365925855999999999, " system-id set");
|
||||
TEST_RESULT_INT(infoPgData.catalogVersion, 201510051, " catalog-version set");
|
||||
TEST_RESULT_INT(infoPgData.controlVersion, 942, " control-version set");
|
||||
|
||||
// infoPgAdd
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
infoPgData.id = 2;
|
||||
infoPgData.id = 3;
|
||||
infoPgData.version = PG_VERSION_96;
|
||||
infoPgData.systemId = 6365925855999999999;
|
||||
infoPgData.catalogVersion = 201510051;
|
||||
infoPgData.controlVersion = 942;
|
||||
infoPgData.systemId = 6399999999999999999;
|
||||
infoPgData.catalogVersion = 201608131;
|
||||
infoPgData.controlVersion = 960;
|
||||
TEST_RESULT_VOID(infoPgAdd(infoPg, &infoPgData), "infoPgAdd");
|
||||
|
||||
InfoPgData infoPgDataTest = infoPgDataCurrent(infoPg);
|
||||
TEST_RESULT_INT(infoPgDataTest.id, 2, " id set");
|
||||
TEST_RESULT_INT(infoPgDataTest.id, 3, " id set");
|
||||
TEST_RESULT_INT(infoPgDataTest.version, PG_VERSION_96, " version set");
|
||||
TEST_RESULT_INT(infoPgDataTest.systemId, 6365925855999999999, " system-id set");
|
||||
TEST_RESULT_INT(infoPgDataTest.catalogVersion, 201510051, " catalog-version set");
|
||||
TEST_RESULT_INT(infoPgDataTest.controlVersion, 942, " control-version set");
|
||||
TEST_RESULT_INT(infoPgDataTest.systemId, 6399999999999999999, " system-id set");
|
||||
TEST_RESULT_INT(infoPgDataTest.catalogVersion, 201608131, " catalog-version set");
|
||||
TEST_RESULT_INT(infoPgDataTest.controlVersion, 960, " control-version set");
|
||||
|
||||
// Errors
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user