diff --git a/doc/xml/release.xml b/doc/xml/release.xml index ab1c0fa85..554ca1b1e 100644 --- a/doc/xml/release.xml +++ b/doc/xml/release.xml @@ -48,13 +48,16 @@ + + + -

Update command tests to use standard patterns.

+

Update tests to use standard patterns.

diff --git a/test/src/module/info/infoArchiveTest.c b/test/src/module/info/infoArchiveTest.c index 21d33b607..7b4e96f61 100644 --- a/test/src/module/info/infoArchiveTest.c +++ b/test/src/module/info/infoArchiveTest.c @@ -22,6 +22,8 @@ testRun(void) if (testBegin("InfoArchive")) { // ------------------------------------------------------------------------------------------------------------------------- + TEST_TITLE("move infoArchive to new memory context"); + const Buffer *contentLoad = harnessInfoChecksumZ ( "[db]\n" @@ -39,36 +41,43 @@ testRun(void) MEM_CONTEXT_TEMP_BEGIN() { TEST_ASSIGN(info, infoArchiveNewLoad(ioBufferReadNew(contentLoad)), "load new archive info"); - TEST_RESULT_VOID(infoArchiveMove(info, memContextPrior()), " move info"); + TEST_RESULT_VOID(infoArchiveMove(info, memContextPrior()), "move info"); } MEM_CONTEXT_TEMP_END(); - TEST_RESULT_STR_Z(infoArchiveId(info), "9.4-1", " archiveId set"); - TEST_RESULT_PTR(infoArchivePg(info), info->pub.infoPg, " infoPg set"); - TEST_RESULT_STR(infoArchiveCipherPass(info), NULL, " no cipher sub"); + TEST_RESULT_STR_Z(infoArchiveId(info), "9.4-1", "archiveId set"); + TEST_RESULT_PTR(infoArchivePg(info), info->pub.infoPg, "infoPg set"); + TEST_RESULT_STR(infoArchiveCipherPass(info), NULL, "no cipher sub"); + + // ------------------------------------------------------------------------------------------------------------------------- + TEST_TITLE("infoArchive save (in memory)"); // Save info and verify Buffer *contentSave = bufNew(0); TEST_RESULT_VOID(infoArchiveSave(info, ioBufferWriteNew(contentSave)), "info archive save"); - TEST_RESULT_STR(strNewBuf(contentSave), strNewBuf(contentLoad), " check save"); + TEST_RESULT_STR(strNewBuf(contentSave), strNewBuf(contentLoad), "check save"); + + // ------------------------------------------------------------------------------------------------------------------------- + TEST_TITLE("create content via new object"); // Create the same content by creating a new object - // ------------------------------------------------------------------------------------------------------------------------- TEST_ASSIGN( info, infoArchiveNew(PG_VERSION_94, 6569239123849665679, NULL), "infoArchiveNew() - no sub cipher"); - TEST_RESULT_STR_Z(infoArchiveId(info), "9.4-1", " archiveId set"); - TEST_RESULT_PTR(infoArchivePg(info), info->pub.infoPg, " infoPg set"); - TEST_RESULT_STR(infoArchiveCipherPass(info), NULL, " no cipher sub"); - TEST_RESULT_INT(infoPgDataTotal(infoArchivePg(info)), 1, " history set"); + TEST_RESULT_STR_Z(infoArchiveId(info), "9.4-1", "archiveId set"); + TEST_RESULT_PTR(infoArchivePg(info), info->pub.infoPg, "infoPg set"); + TEST_RESULT_STR(infoArchiveCipherPass(info), NULL, "no cipher sub"); + TEST_RESULT_INT(infoPgDataTotal(infoArchivePg(info)), 1, "history set"); Buffer *contentCompare = bufNew(0); TEST_RESULT_VOID(infoArchiveSave(info, ioBufferWriteNew(contentCompare)), "info archive save"); - TEST_RESULT_STR(strNewBuf(contentCompare), strNewBuf(contentSave), " check save"); + TEST_RESULT_STR(strNewBuf(contentCompare), strNewBuf(contentSave), "check save"); - // Remove both files and recreate from scratch with cipher // ------------------------------------------------------------------------------------------------------------------------- + TEST_TITLE("create with cipher"); + + // Recreate from scratch with cipher TEST_ASSIGN( info, infoArchiveNew( @@ -77,29 +86,33 @@ testRun(void) contentSave = bufNew(0); - TEST_RESULT_VOID(infoArchiveSave(info, ioBufferWriteNew(contentSave)), " save new with cipher"); + TEST_RESULT_VOID(infoArchiveSave(info, ioBufferWriteNew(contentSave)), "save new with cipher"); - TEST_ASSIGN(info, infoArchiveNewLoad(ioBufferReadNew(contentSave)), " load encrypted archive info"); - TEST_RESULT_STR_Z(infoArchiveId(info), "10-1", " archiveId set"); - TEST_RESULT_PTR(infoArchivePg(info), infoArchivePg(info), " infoPg set"); - TEST_RESULT_STR_Z(infoArchiveCipherPass(info), - "zWa/6Xtp-IVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO", " cipher sub set"); - TEST_RESULT_INT(infoPgDataTotal(infoArchivePg(info)), 1, " history set"); + TEST_ASSIGN(info, infoArchiveNewLoad(ioBufferReadNew(contentSave)), "load encrypted archive info"); + TEST_RESULT_STR_Z(infoArchiveId(info), "10-1", "archiveId set"); + TEST_RESULT_PTR(infoArchivePg(info), infoArchivePg(info), "infoPg set"); + TEST_RESULT_STR_Z( + infoArchiveCipherPass(info), "zWa/6Xtp-IVZC5444yXB+cgFDFl7MxGlgkZSaoPvTGirhPygu4jOKOXf9LO4vjfO", "cipher sub set"); + TEST_RESULT_INT(infoPgDataTotal(infoArchivePg(info)), 1, "history set"); // ------------------------------------------------------------------------------------------------------------------------- + TEST_TITLE("increment history"); + InfoPgData infoPgData = {0}; TEST_RESULT_VOID(infoArchivePgSet(info, PG_VERSION_94, 6569239123849665679), "add another infoPg"); - TEST_RESULT_INT(infoPgDataTotal(infoArchivePg(info)), 2, " history incremented"); - TEST_ASSIGN(infoPgData, infoPgDataCurrent(infoArchivePg(info)), " get current infoPgData"); - TEST_RESULT_INT(infoPgData.version, PG_VERSION_94, " version set"); - TEST_RESULT_UINT(infoPgData.systemId, 6569239123849665679, " systemId set"); + TEST_RESULT_INT(infoPgDataTotal(infoArchivePg(info)), 2, "history incremented"); + TEST_ASSIGN(infoPgData, infoPgDataCurrent(infoArchivePg(info)), "get current infoPgData"); + TEST_RESULT_INT(infoPgData.version, PG_VERSION_94, "version set"); + TEST_RESULT_UINT(infoPgData.systemId, 6569239123849665679, "systemId set"); - // Free // ------------------------------------------------------------------------------------------------------------------------- + TEST_TITLE("object free"); + TEST_RESULT_VOID(infoArchiveFree(info), "infoArchiveFree() - free archive info"); - // infoArchiveIdHistoryMatch() // ------------------------------------------------------------------------------------------------------------------------- + TEST_TITLE("infoArchiveIdHistoryMatch()"); + contentLoad = harnessInfoChecksumZ ( "[db]\n" @@ -113,9 +126,9 @@ testRun(void) ); TEST_ASSIGN(info, infoArchiveNewLoad(ioBufferReadNew(contentLoad)), "new archive info"); - TEST_RESULT_STR_Z(infoArchiveIdHistoryMatch(info, 2, 90500, 6626363367545678089), "9.5-2", " full match found"); + TEST_RESULT_STR_Z(infoArchiveIdHistoryMatch(info, 2, 90500, 6626363367545678089), "9.5-2", "full match found"); - TEST_RESULT_STR_Z(infoArchiveIdHistoryMatch(info, 2, 90400, 6625592122879095702), "9.4-1", " partial match found"); + TEST_RESULT_STR_Z(infoArchiveIdHistoryMatch(info, 2, 90400, 6625592122879095702), "9.4-1", "partial match found"); TEST_ERROR(infoArchiveIdHistoryMatch(info, 2, 90400, 6625592122879095799), ArchiveMismatchError, "unable to retrieve the archive id for database version '9.4' and system-id '6625592122879095799'"); @@ -127,6 +140,9 @@ testRun(void) // ***************************************************************************************************************************** if (testBegin("infoArchiveLoadFile() and infoArchiveSaveFile()")) { + // ------------------------------------------------------------------------------------------------------------------------- + TEST_TITLE("load archive info file - error"); + TEST_ERROR( infoArchiveLoadFile(storageTest, STRDEF(INFO_ARCHIVE_FILE), cipherTypeNone, NULL), FileMissingError, "unable to load info file '" TEST_PATH "/archive.info' or '" TEST_PATH "/archive.info.copy':\n" @@ -137,15 +153,18 @@ testRun(void) "HINT: has a stanza-create been performed?\n" "HINT: use --no-archive-check to disable archive checks during backup if you have an alternate archiving scheme."); + // ------------------------------------------------------------------------------------------------------------------------- + TEST_TITLE("save and load archive info file"); + InfoArchive *infoArchive = infoArchiveNew(PG_VERSION_10, 6569239123849665999, NULL); TEST_RESULT_VOID( infoArchiveSaveFile(infoArchive, storageTest, STRDEF(INFO_ARCHIVE_FILE), cipherTypeNone, NULL), "save archive info"); TEST_ASSIGN(infoArchive, infoArchiveLoadFile(storageTest, STRDEF(INFO_ARCHIVE_FILE), cipherTypeNone, NULL), "load main"); - TEST_RESULT_UINT(infoPgDataCurrent(infoArchivePg(infoArchive)).systemId, 6569239123849665999, " check file loaded"); + TEST_RESULT_UINT(infoPgDataCurrent(infoArchivePg(infoArchive)).systemId, 6569239123849665999, "check file loaded"); - storageRemoveP(storageTest, STRDEF(INFO_ARCHIVE_FILE), .errorOnMissing = true); + HRN_STORAGE_REMOVE(storageTest, INFO_ARCHIVE_FILE, .errorOnMissing = true, .comment = "remove main so only copy exists"); TEST_ASSIGN(infoArchive, infoArchiveLoadFile(storageTest, STRDEF(INFO_ARCHIVE_FILE), cipherTypeNone, NULL), "load copy"); - TEST_RESULT_UINT(infoPgDataCurrent(infoArchivePg(infoArchive)).systemId, 6569239123849665999, " check file loaded"); + TEST_RESULT_UINT(infoPgDataCurrent(infoArchivePg(infoArchive)).systemId, 6569239123849665999, "check file loaded"); } }