| #include "error_messages.hpp" | |
| #include <string> | |
| #include <gmock/gmock.h> // IWYU pragma: keep | |
| #include <gtest/gtest.h> // IWYU pragma: keep | |
| #include <nlohmann/json.hpp> | |
| namespace redfish { | |
| namespace messages { | |
| namespace { | |
| TEST(ErrorMessagesTest, | |
| MoveErrorsToErrorJsonDosentClearSourceOnBadlyFormattedSource) { | |
| std::string source_json_string = | |
| R"({"test": "this message should not be deleted"})"; | |
| nlohmann::json target; | |
| nlohmann::json source = nlohmann::json::parse(source_json_string); | |
| moveErrorsToErrorJson(target, source); | |
| // Expect target to be correctly populated with error code | |
| std::string expected_target_json = R"( | |
| { | |
| "error": { | |
| "@Message.ExtendedInfo": [{ "test": "this message should not be deleted" }], | |
| "code": "Base.1.11.0.GeneralError", | |
| "message": "A general error has occurred. See Resolution for information on how to resolve the error." | |
| } | |
| } | |
| )"; | |
| EXPECT_EQ(target, nlohmann::json::parse(expected_target_json)); | |
| EXPECT_EQ(source, nlohmann::json::parse(source_json_string)); | |
| } | |
| } // namespace | |
| } // namespace messages | |
| } // namespace redfish |