mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-14 10:13:05 +02:00
Fix non-JSON ini values in tests.
A number of tests used invalid JSON values where an error was expected or the value would be ignored. Update these tests to use valid JSON values so all values in the file can be validated even if they are not used.
This commit is contained in:
parent
9d8f6d9fc2
commit
cbf5dd19c2
@ -65,26 +65,27 @@ testRun(void)
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
iniBuf = BUFSTRZ(
|
||||
"[section]\n"
|
||||
"=value");
|
||||
"=\"value\"");
|
||||
|
||||
TEST_ERROR(
|
||||
iniLoad(ioBufferReadNew(iniBuf), testIniLoadCallback, result), FormatError,
|
||||
"key is zero-length at line 1: =value");
|
||||
"key is zero-length at line 1: =\"value\"");
|
||||
|
||||
// One section
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("one section");
|
||||
|
||||
iniBuf = BUFSTRZ(
|
||||
"# comment\n"
|
||||
"[section1]\n"
|
||||
"key1=value1\n"
|
||||
"key2=value2");
|
||||
"key1=\"value1\"\n"
|
||||
"key2=\"value2\"\n");
|
||||
result = strNew("");
|
||||
|
||||
TEST_RESULT_VOID(iniLoad(ioBufferReadNew(iniBuf), testIniLoadCallback, result), "load ini");
|
||||
TEST_RESULT_STR_Z(
|
||||
result,
|
||||
"section1:key1:value1\n"
|
||||
"section1:key2:value2\n",
|
||||
"section1:key1:\"value1\"\n"
|
||||
"section1:key2:\"value2\"\n",
|
||||
" check ini");
|
||||
|
||||
// Two sections
|
||||
@ -92,22 +93,22 @@ testRun(void)
|
||||
iniBuf = BUFSTRZ(
|
||||
"# comment\n"
|
||||
"[section1]\n"
|
||||
"key1=value1\n"
|
||||
"key2=value2\n"
|
||||
"key1=\"value1\"\n"
|
||||
"key2=\"value2\"\n"
|
||||
"\n"
|
||||
"[section2]\n"
|
||||
"key1=\n"
|
||||
"\n"
|
||||
"key2=value2");
|
||||
"key2=\"value2\"");
|
||||
result = strNew("");
|
||||
|
||||
TEST_RESULT_VOID(iniLoad(ioBufferReadNew(iniBuf), testIniLoadCallback, result), "load ini");
|
||||
TEST_RESULT_STR_Z(
|
||||
result,
|
||||
"section1:key1:value1\n"
|
||||
"section1:key2:value2\n"
|
||||
"section2:key1:\n"
|
||||
"section2:key2:value2\n",
|
||||
"section1:key1:\"value1\"\n"
|
||||
"section1:key2:\"value2\"\n"
|
||||
"section2:key1:\n"
|
||||
"section2:key2:\"value2\"\n",
|
||||
" check ini");
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ testRun(void)
|
||||
"db-version=\"9.4\"\n"
|
||||
"\n"
|
||||
"[ignore-section]\n"
|
||||
"key1=value1\n"
|
||||
"key1=\"value1\"\n"
|
||||
"\n"
|
||||
"[db:history]\n"
|
||||
"1={\"db-catalog-version\":201409291,\"db-control-version\":942,\"db-system-id\":6569239123849665679,"
|
||||
|
@ -18,10 +18,10 @@ testInfoBackupSaveCallback(void *data, const String *sectionNext, InfoSave *info
|
||||
infoSaveValue(infoSaveData, STRDEF("backup:current"), STRDEF("20161219-212741F"), STRDEF("{}"));
|
||||
|
||||
if (infoSaveSection(infoSaveData, STRDEF("db:backup"), sectionNext))
|
||||
infoSaveValue(infoSaveData, STRDEF("db:backup"), STRDEF("key"), STRDEF("value"));
|
||||
infoSaveValue(infoSaveData, STRDEF("db:backup"), STRDEF("key"), STRDEF("\"value\""));
|
||||
|
||||
if (infoSaveSection(infoSaveData, STRDEF("later"), sectionNext))
|
||||
infoSaveValue(infoSaveData, STRDEF("later"), STRDEF("key"), STRDEF("value"));
|
||||
infoSaveValue(infoSaveData, STRDEF("later"), STRDEF("key"), STRDEF("\"value\""));
|
||||
}
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -94,13 +94,13 @@ testRun(void)
|
||||
"db-version=\"9.4\"\n"
|
||||
"\n"
|
||||
"[db:backup]\n"
|
||||
"key=value\n"
|
||||
"key=\"value\"\n"
|
||||
"\n"
|
||||
"[db:history]\n"
|
||||
"1={\"db-id\":6569239123849665679,\"db-version\":\"9.4\"}\n"
|
||||
"\n"
|
||||
"[later]\n"
|
||||
"key=value\n");
|
||||
"key=\"value\"\n");
|
||||
|
||||
String *callbackContent = strNew("");
|
||||
InfoPg *infoPg = NULL;
|
||||
@ -111,8 +111,8 @@ testRun(void)
|
||||
TEST_RESULT_STR_Z(
|
||||
callbackContent,
|
||||
"[backup:current] 20161219-212741F={}\n"
|
||||
"[db:backup] key=value\n"
|
||||
"[later] key=value\n",
|
||||
"[db:backup] key=\"value\"\n"
|
||||
"[later] key=\"value\"\n",
|
||||
" check callback content");
|
||||
TEST_RESULT_INT(lstSize(infoPg->history), 1, " history record added");
|
||||
|
||||
|
@ -2029,7 +2029,7 @@ testRun(void)
|
||||
"backup-timestamp-start=1565282140\n"
|
||||
"backup-timestamp-stop=1565282142\n"
|
||||
"backup-type=\"full\"\n"
|
||||
"ignore-key=ignore-value\n"
|
||||
"ignore-key=\"ignore-value\"\n"
|
||||
"\n"
|
||||
"[backup:db]\n"
|
||||
"db-catalog-version=201409291\n"
|
||||
@ -2037,10 +2037,10 @@ testRun(void)
|
||||
"db-id=1\n"
|
||||
"db-system-id=1000000000000000094\n"
|
||||
"db-version=\"9.4\"\n"
|
||||
"ignore-key=ignore-value\n"
|
||||
"ignore-key=\"ignore-value\"\n"
|
||||
"\n"
|
||||
"[backup:option]\n"
|
||||
"ignore-key=ignore-value\n"
|
||||
"ignore-key=\"ignore-value\"\n"
|
||||
"option-archive-check=true\n"
|
||||
"option-archive-copy=true\n"
|
||||
"option-compress=false\n"
|
||||
@ -2051,27 +2051,27 @@ testRun(void)
|
||||
"pg_data={\"path\":\"/pg/base\",\"type\":\"path\"}\n"
|
||||
"\n"
|
||||
"[ignore-section]\n"
|
||||
"ignore-key=ignore-value\n"
|
||||
"ignore-key=\"ignore-value\"\n"
|
||||
"\n"
|
||||
"[target:file]\n"
|
||||
"pg_data/PG_VERSION={\"checksum\":\"184473f470864e067ee3a22e64b47b0a1c356f29\",\"size\":4,\"timestamp\":1565282114}\n"
|
||||
"\n"
|
||||
"[target:file:default]\n"
|
||||
"group=\"group1\"\n"
|
||||
"ignore-key=ignore-value\n"
|
||||
"ignore-key=\"ignore-value\"\n"
|
||||
"master=true\n"
|
||||
"mode=\"0600\"\n"
|
||||
"user=\"user1\"\n"
|
||||
"\n"
|
||||
"[target:link:default]\n"
|
||||
"ignore-key=ignore-value\n"
|
||||
"ignore-key=\"ignore-value\"\n"
|
||||
"\n"
|
||||
"[target:path]\n"
|
||||
"pg_data={}\n"
|
||||
"\n"
|
||||
"[target:path:default]\n"
|
||||
"group=\"group1\"\n"
|
||||
"ignore-key=ignore-value\n"
|
||||
"ignore-key=\"ignore-value\"\n"
|
||||
"mode=\"0700\"\n"
|
||||
"user=\"user1\"\n"
|
||||
);
|
||||
|
@ -101,7 +101,7 @@ testRun(void)
|
||||
unsigned int iniMax = 100000 * (unsigned int)testScale();
|
||||
|
||||
for (unsigned int keyIdx = 0; keyIdx < iniMax; keyIdx++)
|
||||
strCatFmt(iniStr, "key%u=value%u\n", keyIdx, keyIdx);
|
||||
strCatFmt(iniStr, "key%u=\"value%u\"\n", keyIdx, keyIdx);
|
||||
|
||||
TEST_LOG_FMT("ini size = %s, keys = %u", strPtr(strSizeFormat(strSize(iniStr))), iniMax);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user