| #include "error_messages.hpp" |
| |
| #include "nlohmann/json.hpp" |
| |
| #include <gmock/gmock.h> // IWYU pragma: keep |
| #include <gtest/gtest.h> // IWYU pragma: keep |
| |
| #include <iostream> |
| |
| 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)); |
| } |
| |
| } |
| } |
| } |