diff options
author | Sui Chen <suichen@google.com> | 2022-04-11 09:09:36 +0300 |
---|---|---|
committer | Ed Tanous <edtanous@google.com> | 2023-02-28 00:45:22 +0300 |
commit | d1d411f9eebc1d2ca49eec0700670ba564dac5c8 (patch) | |
tree | 076d80209a4ca8688690cc3c48f83fdb6042b4ec /test/redfish-core | |
parent | af20dd1ccc481af63b528a851bce390a0070ab32 (diff) | |
download | bmcweb-d1d411f9eebc1d2ca49eec0700670ba564dac5c8.tar.xz |
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 <suichen@google.com>
Change-Id: Ia9fc91e5a47036198bf013ff3ea21ea9f6d5259a
Diffstat (limited to 'test/redfish-core')
-rw-r--r-- | test/redfish-core/include/registries_test.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
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 <gtest/gtest.h> // 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 |