Skip to content

Commit 3f0430a

Browse files
committed
Unconditionally allow processing CheckResults in tests
1 parent 7b5eac7 commit 3f0430a

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

lib/icinga/checkresult.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,12 @@ void DslCheckResultProducer::unlock_shared() noexcept
5353
}
5454

5555
CheckResultProducer::Ptr DslCheckResultProducer::m_Instance = new DslCheckResultProducer();
56+
57+
bool TestCheckResultProducer::try_lock_shared() noexcept
58+
{
59+
return true;
60+
}
61+
62+
void TestCheckResultProducer::unlock_shared() noexcept
63+
{
64+
}

lib/icinga/checkresult.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ class DslCheckResultProducer : public CheckResultProducer
8181
static Ptr m_Instance;
8282
};
8383

84+
class TestCheckResultProducer : public CheckResultProducer
85+
{
86+
public:
87+
bool try_lock_shared() noexcept override;
88+
void unlock_shared() noexcept override;
89+
};
90+
8491
}
8592

8693
#endif /* CHECKRESULT_H */

test/icinga-checkable-flapping.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ using namespace icinga;
1010
#ifdef I2_DEBUG
1111
static CheckResult::Ptr MakeCheckResult(ServiceState state)
1212
{
13-
CheckResult::Ptr cr = new CheckResult();
13+
CheckResult::Ptr cr = new CheckResult(new TestCheckResultProducer());
1414

1515
cr->SetState(state);
1616

test/icinga-checkresult.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ BOOST_AUTO_TEST_SUITE(icinga_checkresult)
1515

1616
static CheckResult::Ptr MakeCheckResult(ServiceState state)
1717
{
18-
CheckResult::Ptr cr = new CheckResult();
18+
CheckResult::Ptr cr = new CheckResult(new TestCheckResultProducer());
1919

2020
cr->SetState(state);
2121

test/icinga-dependencies.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ BOOST_AUTO_TEST_CASE(multi_parent)
2727
parentHost1->SetAuthority(true);
2828
parentHost1->SetStateRaw(ServiceCritical);
2929
parentHost1->SetStateType(StateTypeHard);
30-
parentHost1->SetLastCheckResult(new CheckResult());
30+
parentHost1->SetLastCheckResult(new CheckResult(new TestCheckResultProducer()));
3131

3232
Host::Ptr parentHost2 = new Host();
3333
parentHost2->SetActive(true);
@@ -36,7 +36,7 @@ BOOST_AUTO_TEST_CASE(multi_parent)
3636
parentHost2->SetAuthority(true);
3737
parentHost2->SetStateRaw(ServiceOK);
3838
parentHost2->SetStateType(StateTypeHard);
39-
parentHost2->SetLastCheckResult(new CheckResult());
39+
parentHost2->SetLastCheckResult(new CheckResult(new TestCheckResultProducer()));
4040

4141
Host::Ptr childHost = new Host();
4242
childHost->SetActive(true);

0 commit comments

Comments
 (0)