1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00

Add UTF8 strings to manifest and restore tests.

The most likely place to get UTF8 characters is in database names so make sure UTF8 works in the places where database names are processed.
This commit is contained in:
David Steele 2020-01-18 10:46:48 -07:00
parent 19c39fe1e2
commit d9efbc3698
2 changed files with 20 additions and 3 deletions

View File

@ -14,6 +14,11 @@ Test Restore Command
#include "common/harnessInfo.h"
#include "common/harnessStorage.h"
/***********************************************************************************************************************************
Special string constants
***********************************************************************************************************************************/
#define UTF8_DB_NAME "这个用汉语怎么说"
/***********************************************************************************************************************************
Test data for backup.info
***********************************************************************************************************************************/
@ -1050,7 +1055,7 @@ testRun(void)
strLstAddZ(argListClean, "--pg1-path=/pg");
StringList *argList = strLstDup(argListClean);
strLstAddZ(argList, "--db-include=test1");
strLstAddZ(argList, "--db-include=" UTF8_DB_NAME);
harnessCfgLoad(cfgCmdRestore, argList);
Manifest *manifest = NULL;
@ -1078,13 +1083,13 @@ testRun(void)
manifestDbAdd(manifest, &(ManifestDb){.name = STRDEF("postgres"), .id = 12173, .lastSystemId = 12168});
manifestDbAdd(manifest, &(ManifestDb){.name = STRDEF("template0"), .id = 12168, .lastSystemId = 12168});
manifestDbAdd(manifest, &(ManifestDb){.name = STRDEF("template1"), .id = 1, .lastSystemId = 12168});
manifestDbAdd(manifest, &(ManifestDb){.name = STRDEF("test1"), .id = 16384, .lastSystemId = 12168});
manifestDbAdd(manifest, &(ManifestDb){.name = STRDEF(UTF8_DB_NAME), .id = 16384, .lastSystemId = 12168});
manifestFileAdd(
manifest, &(ManifestFile){.name = STRDEF(MANIFEST_TARGET_PGDATA "/" PG_PATH_BASE "/1/" PG_FILE_PGVERSION)});
}
MEM_CONTEXT_END();
TEST_ERROR(restoreSelectiveExpression(manifest), DbMissingError, "database to include 'test1' does not exist");
TEST_ERROR(restoreSelectiveExpression(manifest), DbMissingError, "database to include '" UTF8_DB_NAME "' does not exist");
TEST_RESULT_LOG("P00 DETAIL: databases found for selective restore (1)");

View File

@ -10,6 +10,11 @@ Test Backup Manifest Handler
#include "common/harnessInfo.h"
/***********************************************************************************************************************************
Special string constants
***********************************************************************************************************************************/
#define SHRUG_EMOJI "¯\\_(ツ)_/¯"
/***********************************************************************************************************************************
Test Run
***********************************************************************************************************************************/
@ -1657,6 +1662,7 @@ testRun(void)
"postgres={\"db-id\":12173,\"db-last-system-id\":12168}\n" \
"template0={\"db-id\":12168,\"db-last-system-id\":12168}\n" \
"template1={\"db-id\":1,\"db-last-system-id\":12168}\n" \
SHRUG_EMOJI "={\"db-id\":18000,\"db-last-system-id\":12168}\n"
#define TEST_MANIFEST_FILE \
"\n" \
@ -1780,6 +1786,12 @@ testRun(void)
varLstAdd(dbRow, varNewUInt64(12168));
varLstAdd(dbList, varNewVarLst(dbRow));
dbRow = varLstNew();
varLstAdd(dbRow, varNewUInt64(18000));
varLstAdd(dbRow, varNewStrZ(SHRUG_EMOJI));
varLstAdd(dbRow, varNewUInt64(12168));
varLstAdd(dbList, varNewVarLst(dbRow));
TEST_RESULT_VOID(
manifestBuildComplete(
manifest, 1565282140, STRDEF("285/89000028"), STRDEF("000000030000028500000089"), 1565282142,