Skip to content

Commit

Permalink
Add testGenerateLogsSupportArchive.
Browse files Browse the repository at this point in the history
  • Loading branch information
herve-er committed May 6, 2024
1 parent fa7eb38 commit 7f7b77e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 21 additions & 1 deletion test/libcommonserver/log/testlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,11 @@ void TestLog::testCopyLogsTo(void) {
CPPUNIT_ASSERT_EQUAL(true, IoHelper::copyFileOrDirectory(tempDir.path / "test.log.gz", logDir / "test.log.gz", err));
CPPUNIT_ASSERT_EQUAL(IoErrorSuccess, err);

CPPUNIT_ASSERT_EQUAL(true, IoHelper::deleteDirectory(tempDir.path / "test.log.gz", err));
IoHelper::deleteDirectory(tempDir.path / "test.log.gz", err);

exitCode = Log::instance()->copyLogsTo(tempDir.path, false, cause);
IoHelper::deleteDirectory(logDir / "test.log.gz", err);

CPPUNIT_ASSERT_EQUAL(ExitCauseUnknown, cause);
CPPUNIT_ASSERT_EQUAL(ExitCodeOk, exitCode);

Expand Down Expand Up @@ -249,4 +251,22 @@ void TestLog::testGenerateUserDescriptionFile(void) {
}
}

void TestLog::testGenerateLogsSupportArchive(void) {
{
TemporaryDirectory tempDir;
const SyncPath archiveFile = tempDir.path / "logs_support.tar.gz";
ExitCause cause = ExitCauseUnknown;

ExitCode code = Log::instance()->generateLogsSupportArchive(true, tempDir.path, archiveFile.filename(), cause);
CPPUNIT_ASSERT_EQUAL(ExitCauseUnknown, cause);
CPPUNIT_ASSERT_EQUAL(ExitCodeOk, code);

bool exists = false;
IoError err = IoErrorSuccess;
CPPUNIT_ASSERT_EQUAL(true, IoHelper::checkIfPathExists(archiveFile, exists, err));
CPPUNIT_ASSERT_EQUAL(IoErrorSuccess, err);
CPPUNIT_ASSERT_EQUAL(true, exists);
}
}

} // namespace KDC
2 changes: 2 additions & 0 deletions test/libcommonserver/log/testlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class TestLog : public CppUnit::TestFixture {
CPPUNIT_TEST(testCopyParmsDbTo);
CPPUNIT_TEST(testCompressLogs);
CPPUNIT_TEST(testGenerateUserDescriptionFile);
CPPUNIT_TEST(testGenerateLogsSupportArchive);
CPPUNIT_TEST_SUITE_END();

public:
Expand All @@ -45,6 +46,7 @@ class TestLog : public CppUnit::TestFixture {
void testCopyParmsDbTo(void);
void testCompressLogs(void);
void testGenerateUserDescriptionFile(void);
void testGenerateLogsSupportArchive(void);
};

} // namespace KDC

0 comments on commit 7f7b77e

Please sign in to comment.