Validate the priority of an LED is same
Need to make sure that the priority of a particular LED is the same
across all groups, it needs to throw the std::runtime_error if not
the same.
Tested: Manually changed the JSON file to have priority of a particular
LED different across groups and saw ledManager throw a runtime exception
and failed to run.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I9d3e788dd86defb9a781dc958976b51ec7d3fd19
diff --git a/test/utest-led-json.cpp b/test/utest-led-json.cpp
index 32d89a8..f0ca022 100644
--- a/test/utest-led-json.cpp
+++ b/test/utest-led-json.cpp
@@ -65,4 +65,25 @@
{
static constexpr auto jsonPath = "config/led-group-config-malformed.json";
ASSERT_THROW(loadJsonConfig(jsonPath), std::exception);
+}
+
+TEST(validatePriority, testGoodPriority)
+{
+ PriorityMap priorityMap{};
+ validatePriority("heartbeat", phosphor::led::Layout::Blink, priorityMap);
+ validatePriority("power", phosphor::led::Layout::On, priorityMap);
+
+ ASSERT_EQ(priorityMap.at("heartbeat"), phosphor::led::Layout::Blink);
+ ASSERT_EQ(priorityMap.at("power"), phosphor::led::Layout::On);
+}
+
+TEST(validatePriority, testBadPriority)
+{
+ PriorityMap priorityMap{};
+ validatePriority("heartbeat", phosphor::led::Layout::Blink, priorityMap);
+
+ ASSERT_EQ(priorityMap.at("heartbeat"), phosphor::led::Layout::Blink);
+ ASSERT_THROW(
+ validatePriority("heartbeat", phosphor::led::Layout::On, priorityMap),
+ std::runtime_error);
}
\ No newline at end of file