From d1d411f9eebc1d2ca49eec0700670ba564dac5c8 Mon Sep 17 00:00:00 2001 From: Sui Chen Date: Sun, 10 Apr 2022 23:09:36 -0700 Subject: Move getMessage and getMessageFromRegistry to cpp and add test This change moves getMessage and getMessageFromRegistry to a .cpp file so that they can be easily tested. Tested: Unit test passes Signed-off-by: Sui Chen Change-Id: Ia9fc91e5a47036198bf013ff3ea21ea9f6d5259a --- test/redfish-core/include/registries_test.cpp | 32 +++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test/redfish-core') diff --git a/test/redfish-core/include/registries_test.cpp b/test/redfish-core/include/registries_test.cpp index 5c47128ca7..25f2c60deb 100644 --- a/test/redfish-core/include/registries_test.cpp +++ b/test/redfish-core/include/registries_test.cpp @@ -1,4 +1,5 @@ #include "registries.hpp" +#include "registries/openbmc_message_registry.hpp" #include // IWYU pragma: keep @@ -22,5 +23,36 @@ TEST(FillMessageArgs, ArgsAreFilledCorrectly) EXPECT_EQ(fillMessageArgs({}, "%foo"), ""); } +TEST(RedfishRegistries, GetMessageFromRegistry) +{ + const redfish::registries::Message* msg = + redfish::registries::getMessageFromRegistry( + "Non-Existent", redfish::registries::openbmc::registry); + ASSERT_EQ(msg, nullptr); + + const redfish::registries::Message* msg1 = + redfish::registries::getMessageFromRegistry( + "ServiceStarted", redfish::registries::openbmc::registry); + ASSERT_NE(msg1, nullptr); + + EXPECT_EQ(std::string(msg1->description), + "Indicates that a service has started successfully."); + EXPECT_EQ(std::string(msg1->message), + "Service %1 has started successfully."); + EXPECT_EQ(std::string(msg1->messageSeverity), "OK"); + EXPECT_EQ(msg1->numberOfArgs, 1); + EXPECT_EQ(std::string(msg1->resolution), "None."); +} + +TEST(RedfishRegistries, GetMessage) +{ + const redfish::registries::Message* msg = + redfish::registries::getMessage("OpenBMC.1.0.Non_Existent_Message"); + ASSERT_EQ(msg, nullptr); + + msg = redfish::registries::getMessage("OpenBMC.1.0.ServiceStarted"); + ASSERT_NE(msg, nullptr); +} + } // namespace } // namespace redfish::registries -- cgit v1.2.3