1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-01-30 05:39:12 +02:00

Allow key replacements in TEST_ERROR*() macros.

Allow standard replacements (e.g. {[path]}) in TEST_ERROR*() macros.

Update command/archive-push unit test as an example of usage.
This commit is contained in:
David Steele 2021-03-23 18:20:26 -04:00
parent b2440947fb
commit 5876048675
2 changed files with 6 additions and 12 deletions

View File

@ -106,7 +106,7 @@ Test that an expected error is actually thrown and error when it isn't
{ \ { \
TEST_ERROR_catch = true; \ TEST_ERROR_catch = true; \
\ \
if (strcmp(errorMessage(), errorMessageExpected) != 0 || errorType() != &errorTypeExpected) \ if (strcmp(errorMessage(), hrnReplaceKey(errorMessageExpected)) != 0 || errorType() != &errorTypeExpected) \
THROW_FMT( \ THROW_FMT( \
TestError, "EXPECTED %s: %s\n\n BUT GOT %s: %s\n\nTHROWN AT:\n%s", errorTypeName(&errorTypeExpected), \ TestError, "EXPECTED %s: %s\n\n BUT GOT %s: %s\n\nTHROWN AT:\n%s", errorTypeName(&errorTypeExpected), \
errorMessageExpected, errorName(), errorMessage(), errorStackTrace()); \ errorMessageExpected, errorName(), errorMessage(), errorStackTrace()); \

View File

@ -300,11 +300,8 @@ testRun(void)
TEST_ERROR( TEST_ERROR(
cmdArchivePush(), ArchiveMismatchError, cmdArchivePush(), ArchiveMismatchError,
strZ( "WAL file '{[path]}/pg/pg_wal/000000010000000100000001' version 10, system-id 18072658121562454734 do not match"
strNewFmt( " stanza version 11, system-id 18072658121562454734");
"WAL file '%s/pg/pg_wal/000000010000000100000001' version 10, system-id 18072658121562454734 do not match"
" stanza version 11, system-id 18072658121562454734",
testPath())));
memset(bufPtr(walBuffer1), 0, bufSize(walBuffer1)); memset(bufPtr(walBuffer1), 0, bufSize(walBuffer1));
pgWalTestToBuffer((PgWal){.version = PG_VERSION_11, .systemId = 0xECAFECAFECAFECAF}, walBuffer1); pgWalTestToBuffer((PgWal){.version = PG_VERSION_11, .systemId = 0xECAFECAFECAFECAF}, walBuffer1);
@ -313,11 +310,8 @@ testRun(void)
TEST_ERROR( TEST_ERROR(
cmdArchivePush(), ArchiveMismatchError, cmdArchivePush(), ArchiveMismatchError,
strZ( "WAL file '{[path]}/pg/pg_wal/000000010000000100000001' version 11, system-id 17055110554209741999 do not match"
strNewFmt( " stanza version 11, system-id 18072658121562454734");
"WAL file '%s/pg/pg_wal/000000010000000100000001' version 11, system-id 17055110554209741999 do not match"
" stanza version 11, system-id 18072658121562454734",
testPath())));
// Generate valid WAL and push them // Generate valid WAL and push them
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
@ -532,7 +526,7 @@ testRun(void)
strZ( strZ(
strNewFmt( strNewFmt(
"archive-push command encountered error(s):\n" "archive-push command encountered error(s):\n"
"repo2: [FileOpenError] unable to open file '" TEST_PATH "/repo2/archive/test/11-1/0000000100000001" "repo2: [FileOpenError] unable to open file '{[path]}/repo2/archive/test/11-1/0000000100000001"
"/000000010000000100000002-%s' for write: [13] Permission denied", walBuffer2Sha1))); "/000000010000000100000002-%s' for write: [13] Permission denied", walBuffer2Sha1)));
TEST_RESULT_BOOL( TEST_RESULT_BOOL(