summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2023-02-15 02:05:48 +0300
committerEd Tanous <ed@tanous.net>2023-03-11 03:50:32 +0300
commit33c6b58026e5dd3bc600d152a07b95f863bfa1a7 (patch)
tree17d8803445b5310f48eba160c2fc488a70fcd215 /test
parent98fe740b59a96fd4d4232655f820da168129f090 (diff)
downloadbmcweb-33c6b58026e5dd3bc600d152a07b95f863bfa1a7.tar.xz
Remove body member from Request
Per cpp core guidelines, these should be methods. Tested: on last patchset of the series. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Ib16479db9d2b68da68e7ad6e825c7e205c64f1de
Diffstat (limited to 'test')
-rw-r--r--test/redfish-core/include/utils/json_utils_test.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/test/redfish-core/include/utils/json_utils_test.cpp b/test/redfish-core/include/utils/json_utils_test.cpp
index b4d1062b24..e97edf9641 100644
--- a/test/redfish-core/include/utils/json_utils_test.cpp
+++ b/test/redfish-core/include/utils/json_utils_test.cpp
@@ -271,10 +271,11 @@ TEST(ReadJsonPatch, ValidElementsReturnsTrueResponseOkValuesUnpackedCorrectly)
{
crow::Response res;
std::error_code ec;
- crow::Request req({}, ec);
+ crow::Request req("{\"integer\": 1}", ec);
+
// Ignore errors intentionally
- req.body = "{\"integer\": 1}";
req.req.set(boost::beast::http::field::content_type, "application/json");
+
int64_t integer = 0;
ASSERT_TRUE(readJsonPatch(req, res, "integer", integer));
EXPECT_EQ(res.result(), boost::beast::http::status::ok);
@@ -286,9 +287,8 @@ TEST(ReadJsonPatch, EmptyObjectReturnsFalseResponseBadRequest)
{
crow::Response res;
std::error_code ec;
- crow::Request req({}, ec);
+ crow::Request req("{}", ec);
// Ignore errors intentionally
- req.body = "{}";
std::optional<int64_t> integer = 0;
ASSERT_FALSE(readJsonPatch(req, res, "integer", integer));
@@ -300,10 +300,9 @@ TEST(ReadJsonPatch, OdataIgnored)
{
crow::Response res;
std::error_code ec;
- crow::Request req({}, ec);
+ crow::Request req(R"({"@odata.etag": "etag", "integer": 1})", ec);
req.req.set(boost::beast::http::field::content_type, "application/json");
// Ignore errors intentionally
- req.body = R"({"@odata.etag": "etag", "integer": 1})";
std::optional<int64_t> integer = 0;
ASSERT_TRUE(readJsonPatch(req, res, "integer", integer));
@@ -316,9 +315,8 @@ TEST(ReadJsonPatch, OnlyOdataGivesNoOperation)
{
crow::Response res;
std::error_code ec;
- crow::Request req({}, ec);
+ crow::Request req(R"({"@odata.etag": "etag"})", ec);
// Ignore errors intentionally
- req.body = R"({"@odata.etag": "etag"})";
std::optional<int64_t> integer = 0;
ASSERT_FALSE(readJsonPatch(req, res, "integer", integer));
@@ -330,10 +328,9 @@ TEST(ReadJsonAction, ValidElementsReturnsTrueResponseOkValuesUnpackedCorrectly)
{
crow::Response res;
std::error_code ec;
- crow::Request req({}, ec);
+ crow::Request req("{\"integer\": 1}", ec);
req.req.set(boost::beast::http::field::content_type, "application/json");
// Ignore errors intentionally
- req.body = "{\"integer\": 1}";
int64_t integer = 0;
ASSERT_TRUE(readJsonAction(req, res, "integer", integer));
@@ -346,10 +343,9 @@ TEST(ReadJsonAction, EmptyObjectReturnsTrueResponseOk)
{
crow::Response res;
std::error_code ec;
- crow::Request req({}, ec);
+ crow::Request req({"{}"}, ec);
req.req.set(boost::beast::http::field::content_type, "application/json");
// Ignore errors intentionally
- req.body = "{}";
std::optional<int64_t> integer = 0;
ASSERT_TRUE(readJsonAction(req, res, "integer", integer));