Skip to content

Commit 4e5e2c8

Browse files
committed
Fix wrong unittest assertions
1 parent 491cbb8 commit 4e5e2c8

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

test/icinga-dependencies.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,19 @@ static void AssertCheckableRedundancyGroup(Checkable::Ptr checkable, int depende
4545
"Dependency group count mismatch for '" << checkable->GetName() << "' - expected=" << groupCount
4646
<< "; got=" << dependencyGroups.size()
4747
);
48-
if (groupCount > 0) {
49-
BOOST_REQUIRE_MESSAGE(!dependencyGroups.empty(), "Checkable '" << checkable->GetName() << "' should have at least one redundancy group.");
50-
auto dependencyGroup(dependencyGroups.front());
48+
49+
for (auto& dependencyGroup : dependencyGroups) {
5150
BOOST_CHECK_MESSAGE(
5251
memberCount == dependencyGroup->GetMemberCount(),
5352
"Dependency group '" << dependencyGroup->GetName() << "' and Checkable '" << checkable->GetName()
5453
<< "' member count mismatch - expected=" << memberCount << "; got="
5554
<< dependencyGroup->GetMemberCount()
5655
);
5756
}
57+
58+
if (groupCount > 0) {
59+
BOOST_REQUIRE_MESSAGE(!dependencyGroups.empty(), "Checkable '" << checkable->GetName() << "' should have at least one redundancy group.");
60+
}
5861
}
5962

6063
BOOST_AUTO_TEST_CASE(multi_parent)
@@ -230,7 +233,20 @@ BOOST_AUTO_TEST_CASE(default_redundancy_group_registration_unregistration)
230233
for (auto& dependency : {depCA2, depCA3, depCA4}) {
231234
bool isAnExactDuplicate = dependency == depCA2;
232235
RegisterDependency(dependency, "");
233-
AssertCheckableRedundancyGroup(childHostD, 2, 2, 2);
236+
237+
if (isAnExactDuplicate) {
238+
BOOST_TEST(childHostC->GetDependencyGroups() == childHostD->GetDependencyGroups(), boost::test_tools::per_element());
239+
}
240+
241+
for (auto& dependencyGroup : childHostD->GetDependencyGroups()) {
242+
if (dependencyGroup->PeekParentCheckableName() == depCA->GetParent()->GetName()) {
243+
BOOST_CHECK_EQUAL(isAnExactDuplicate ? 3 : 1, dependencyGroup->GetMemberCount());
244+
} else {
245+
BOOST_CHECK_EQUAL(2, dependencyGroup->GetMemberCount());
246+
}
247+
BOOST_CHECK_EQUAL(2, childHostD->GetDependencies().size());
248+
}
249+
234250
for (auto& dependencyGroup : childHostC->GetDependencyGroups()) {
235251
if (dependencyGroup->PeekParentCheckableName() == depCA->GetParent()->GetName()) {
236252
// If depCA2 is currently being processed, then the group should have 3 members, that's because

0 commit comments

Comments
 (0)