Skip to content

Commit d799275

Browse files
Fix TestLogger not updating severity by itself
MinSeverity only gets updated if the logger is already active, so we have to set severity after the logger has been activated. Also add a Clear() method to clear existing log messages and assert macros to assert both the existence and absence of a pattern in the log.
1 parent 944e1d6 commit d799275

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

test/base-testloggerfixture.hpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010
#include <boost/test/test_tools.hpp>
1111
#include <future>
1212

13+
#define CHECK_LOG_MESSAGE(pattern, timeout) BOOST_CHECK(ExpectLogPattern(pattern, timeout))
14+
#define REQUIRE_LOG_MESSAGE(pattern, timeout) BOOST_REQUIRE(ExpectLogPattern(pattern, timeout))
15+
16+
#define CHECK_NO_LOG_MESSAGE(pattern, timeout) BOOST_CHECK(!ExpectLogPattern(pattern, timeout))
17+
#define REQUIRE_NO_LOG_MESSAGE(pattern, timeout) BOOST_REQUIRE(!ExpectLogPattern(pattern, timeout))
18+
1319
namespace icinga {
1420

1521
class TestLogger : public Logger
@@ -52,6 +58,13 @@ class TestLogger : public Logger
5258
return ret;
5359
}
5460

61+
void Clear()
62+
{
63+
std::unique_lock lock(m_Mutex);
64+
m_Expects.clear();
65+
m_LogEntries.clear();
66+
}
67+
5568
private:
5669
void ProcessLogEntry(const LogEntry& entry) override
5770
{
@@ -87,9 +100,9 @@ struct TestLoggerFixture
87100
{
88101
TestLoggerFixture()
89102
{
90-
testLogger->SetSeverity(testLogger->SeverityToString(LogDebug));
91103
testLogger->Activate(true);
92104
testLogger->SetActive(true);
105+
testLogger->SetSeverity(TestLogger::SeverityToString(LogDebug));
93106
}
94107

95108
~TestLoggerFixture()

third-party/utf8cpp/extern/ftest

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)