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

Add HRN_STORAGE_PATH_REMOVE() macro.

Update command/archive-push test to show how it is used.
This commit is contained in:
Cynthia Shang 2021-06-02 11:46:54 -04:00 committed by David Steele
parent a97fc6e708
commit c9a8ff27f2
3 changed files with 44 additions and 4 deletions

View File

@ -408,6 +408,25 @@ hrnStoragePathCreate(const Storage *const storage, const char *const path, HrnSt
hrnTestResultEnd();
}
/**********************************************************************************************************************************/
void
hrnStoragePathRemove(const Storage *const storage, const char *const path, HrnStoragePathRemoveParam param)
{
hrnTestResultBegin(__func__, false);
ASSERT(storage != NULL);
ASSERT(path != NULL);
const String *const pathFull = storagePathP(storage, STR(path));
printf("remove path '%s'", strZ(pathFull));
hrnTestResultComment(param.comment);
storagePathRemoveP(storage, pathFull, .recurse = param.recurse, .errorOnMissing = param.errorOnMissing);
hrnTestResultEnd();
}
/**********************************************************************************************************************************/
void
hrnStorageRemove(const Storage *const storage, const char *const file, const TestStorageRemoveParam param)

View File

@ -119,6 +119,27 @@ typedef struct HrnStoragePathCreateParam
void hrnStoragePathCreate(const Storage *const storage, const char *const path, HrnStoragePathCreateParam param);
/***********************************************************************************************************************************
Remove a path
***********************************************************************************************************************************/
typedef struct HrnStoragePathRemoveParam
{
VAR_PARAM_HEADER;
bool errorOnMissing; // Error if the path is missing
bool recurse; // Delete the path and all subpaths/files
const char *comment; // Comment
} HrnStoragePathRemoveParam;
#define HRN_STORAGE_PATH_REMOVE(storage, path, ...) \
do \
{ \
hrnTestLogPrefix(__LINE__); \
hrnStoragePathRemove(storage, path, (HrnStoragePathRemoveParam){VAR_PARAM_INIT, __VA_ARGS__}); \
} \
while (0)
void hrnStoragePathRemove(const Storage *const storage, const char *const path, HrnStoragePathRemoveParam param);
/***********************************************************************************************************************************
Put a file with optional compression and/or encryption
***********************************************************************************************************************************/

View File

@ -466,7 +466,7 @@ testRun(void)
TEST_TITLE("multiple repos, one encrypted");
// Remove old repo
storagePathRemoveP(storageTest, STRDEF("repo"), .errorOnMissing = true, .recurse = true);
HRN_STORAGE_PATH_REMOVE(storageTest, "repo", .errorOnMissing = true, .recurse = true);
// repo2 is encrypted
StorageWrite *infoWrite = storageNewWriteP(storageTest, STRDEF("repo2/archive/test/archive.info"));
@ -810,10 +810,10 @@ testRun(void)
// Check that global.error is created
// -------------------------------------------------------------------------------------------------------------------------
// Remove data from prior tests
storagePathRemoveP(storageSpoolWrite(), STORAGE_SPOOL_ARCHIVE_OUT_STR, .recurse = true);
HRN_STORAGE_PATH_REMOVE(storageSpoolWrite(), STORAGE_SPOOL_ARCHIVE_OUT, .recurse = true);
storagePathCreateP(storageSpoolWrite(), STORAGE_SPOOL_ARCHIVE_OUT_STR);
storagePathRemoveP(storagePgWrite(), STRDEF("pg_xlog/archive_status"), .recurse = true);
HRN_STORAGE_PATH_REMOVE(storagePgWrite(), "pg_xlog/archive_status", .recurse = true);
storagePathCreateP(storagePgWrite(), STRDEF("pg_xlog/archive_status"));
strLstAddZ(argList, TEST_PATH "/pg/pg_xlog");
@ -964,7 +964,7 @@ testRun(void)
// Check that drop functionality works
// -------------------------------------------------------------------------------------------------------------------------
// Remove status files
storagePathRemoveP(storageSpoolWrite(), STORAGE_SPOOL_ARCHIVE_OUT_STR, .recurse = true);
HRN_STORAGE_PATH_REMOVE(storageSpoolWrite(), STORAGE_SPOOL_ARCHIVE_OUT, .recurse = true);
storagePathCreateP(storageSpoolWrite(), STORAGE_SPOOL_ARCHIVE_OUT_STR);
argListTemp = strLstDup(argList);