Skip to content

Commit

Permalink
Add infoArchiveMove() and infoBackupMove().
Browse files Browse the repository at this point in the history
  • Loading branch information
cmwshang authored and dwsteele committed Sep 8, 2020
1 parent 5941f56 commit ecb112f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/info/infoArchive.c
Expand Up @@ -35,6 +35,7 @@ struct InfoArchive
InfoPg *infoPg; // Contents of the DB data
};

OBJECT_DEFINE_MOVE(INFO_ARCHIVE);
OBJECT_DEFINE_FREE(INFO_ARCHIVE);

/***********************************************************************************************************************************
Expand Down
3 changes: 3 additions & 0 deletions src/info/infoArchive.h
Expand Up @@ -43,6 +43,9 @@ Functions
const String *infoArchiveIdHistoryMatch(
const InfoArchive *this, const unsigned int historyId, const unsigned int pgVersion, const uint64_t pgSystemId);

// Move to a new parent mem context
InfoArchive *infoArchiveMove(InfoArchive *this, MemContext *parentNew);

/***********************************************************************************************************************************
Getters/Setters
***********************************************************************************************************************************/
Expand Down
1 change: 1 addition & 0 deletions src/info/infoBackup.c
Expand Up @@ -64,6 +64,7 @@ struct InfoBackup
List *backup; // List of current backups and their associated data
};

OBJECT_DEFINE_MOVE(INFO_BACKUP);
OBJECT_DEFINE_FREE(INFO_BACKUP);

/***********************************************************************************************************************************
Expand Down
3 changes: 3 additions & 0 deletions src/info/infoBackup.h
Expand Up @@ -74,6 +74,9 @@ void infoBackupDataAdd(const InfoBackup *this, const Manifest *manifest);
// Delete backup from the current backup list
void infoBackupDataDelete(const InfoBackup *this, const String *backupDeleteLabel);

// Move to a new parent mem context
InfoBackup *infoBackupMove(InfoBackup *this, MemContext *parentNew);

/***********************************************************************************************************************************
Getters/Setters
***********************************************************************************************************************************/
Expand Down
9 changes: 8 additions & 1 deletion test/src/module/info/infoArchiveTest.c
Expand Up @@ -35,7 +35,14 @@ testRun(void)

InfoArchive *info = NULL;

TEST_ASSIGN(info, infoArchiveNewLoad(ioBufferReadNew(contentLoad)), " load new archive info");
// Load and test move function
MEM_CONTEXT_TEMP_BEGIN()
{
TEST_ASSIGN(info, infoArchiveNewLoad(ioBufferReadNew(contentLoad)), "load new archive 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->infoPg, " infoPg set");
TEST_RESULT_STR(infoArchiveCipherPass(info), NULL, " no cipher sub");
Expand Down
12 changes: 9 additions & 3 deletions test/src/module/info/infoBackupTest.c
Expand Up @@ -40,9 +40,15 @@ testRun(void)
"\"db-version\":\"9.4\"}\n"
);

// Load to make sure ignore-section is ignored
InfoBackup *infoBackup;
TEST_ASSIGN(infoBackup, infoBackupNewLoad(ioBufferReadNew(contentLoad)), " new backup info");
InfoBackup *infoBackup = NULL;

// Load and test move function then make sure ignore-section is ignored
MEM_CONTEXT_TEMP_BEGIN()
{
TEST_ASSIGN(infoBackup, infoBackupNewLoad(ioBufferReadNew(contentLoad)), "new backup info");
TEST_RESULT_VOID(infoBackupMove(infoBackup, memContextPrior()), " move info");
}
MEM_CONTEXT_TEMP_END();

// Save to verify with new created info backup
Buffer *contentSave = bufNew(0);
Expand Down

0 comments on commit ecb112f

Please sign in to comment.