Simplify requestPrefersHtml unit test
This unit test constructs its own Request object, loads keys in, and
then pulls the keys back out. As a matter of being a "unit" test, it
shouldn't be tied to the Request object. This change came up when
changing the Request object constructor in the following patch.
Tested:
Unit test, CI coverage.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I6e56f047c506d55900228da26fdc021bdba887aa
diff --git a/include/ut/http_utility_test.cpp b/include/ut/http_utility_test.cpp
index 164f51d..32591a4 100644
--- a/include/ut/http_utility_test.cpp
+++ b/include/ut/http_utility_test.cpp
@@ -4,23 +4,14 @@
TEST(HttpUtility, requestPrefersHtml)
{
- boost::beast::http::request<boost::beast::http::string_body> req{};
-
- req.set("Accept", "*/*, application/octet-stream");
- crow::Request req1(req);
EXPECT_FALSE(
- http_helpers::requestPrefersHtml(req1.getHeaderValue("Accept")));
- EXPECT_TRUE(http_helpers::isOctetAccepted(req1.getHeaderValue("Accept")));
+ http_helpers::requestPrefersHtml("*/*, application/octet-stream"));
+ EXPECT_TRUE(http_helpers::isOctetAccepted("*/*, application/octet-stream"));
- req.set("Accept", "text/html, application/json");
- crow::Request req2(req);
EXPECT_TRUE(
- http_helpers::requestPrefersHtml(req2.getHeaderValue("Accept")));
- EXPECT_FALSE(http_helpers::isOctetAccepted(req2.getHeaderValue("Accept")));
+ http_helpers::requestPrefersHtml("text/html, application/json"));
+ EXPECT_FALSE(http_helpers::isOctetAccepted("text/html, application/json"));
- req.set("Accept", "application/json");
- crow::Request req3(req);
- EXPECT_FALSE(
- http_helpers::requestPrefersHtml(req3.getHeaderValue("Accept")));
- EXPECT_FALSE(http_helpers::isOctetAccepted(req3.getHeaderValue("Accept")));
+ EXPECT_FALSE(http_helpers::requestPrefersHtml("application/json"));
+ EXPECT_FALSE(http_helpers::isOctetAccepted("application/json"));
}