diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Jamfile.jam | 2 | ||||
-rw-r--r-- | test/fixtures/userAgent.json | 14 | ||||
-rw-r--r-- | test/test-ingest.cpp | 15 | ||||
-rw-r--r-- | test/test-util.hpp | 3 |
4 files changed, 34 insertions, 0 deletions
diff --git a/test/Jamfile.jam b/test/Jamfile.jam index 0542a73..217feec 100644 --- a/test/Jamfile.jam +++ b/test/Jamfile.jam @@ -5,10 +5,12 @@ lib stdc++fs ; path-constant src : ../src ; path-constant test : . ; +path-constant fixtures : fixtures ; project WebStat-Testing : requirements <define>SRC=\"$(src)\" <define>TEST=\"$(test)\" + <define>FIXTURES=\"$(fixtures)\" <library>$(src)//webstat ; diff --git a/test/fixtures/userAgent.json b/test/fixtures/userAgent.json new file mode 100644 index 0000000..a3a8fcb --- /dev/null +++ b/test/fixtures/userAgent.json @@ -0,0 +1,14 @@ +{ + "agent_type": "Browser", + "agent_name": "Chrome", + "agent_version": "140.0.0.0", + "os_type": "Linux", + "os_name": "Linux", + "os_versionName": "", + "os_versionNumber": "", + "os_producer": "", + "os_producerURL": "", + "linux_distibution": "Null", + "agent_language": "", + "agent_languageTag": "" +} diff --git a/test/test-ingest.cpp b/test/test-ingest.cpp index fd7ad65..9b21e44 100644 --- a/test/test-ingest.cpp +++ b/test/test-ingest.cpp @@ -208,6 +208,21 @@ BOOST_AUTO_TEST_CASE(StoreLog, *boost::unit_test::depends_on("I/StoreLogLine")) BOOST_AUTO_TEST_SUITE_END(); +BOOST_AUTO_TEST_CASE(FetchMockUserAgentDetail) +{ + const auto uaDetailReq = WebStat::curlGetUserAgentDetail( + R"(Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36)", + (FIXTURE_URL_BASE + "/userAgent.json").c_str()); + BOOST_REQUIRE(uaDetailReq); + BOOST_REQUIRE_EQUAL(CURLE_OK, curl_easy_perform(uaDetailReq->hnd.get())); + + BOOST_TEST_CONTEXT(uaDetailReq->result) { + BOOST_CHECK(uaDetailReq->result.contains(R"("agent_type":)")); + BOOST_CHECK(uaDetailReq->result.contains(R"("os_type":)")); + BOOST_CHECK(uaDetailReq->result.contains(R"("Chrome")")); + } +} + BOOST_AUTO_TEST_CASE(FetchRealUserAgentDetail, *boost::unit_test::disabled()) { const auto uaDetailReq = WebStat::curlGetUserAgentDetail( diff --git a/test/test-util.hpp b/test/test-util.hpp index c17418f..ac96ee6 100644 --- a/test/test-util.hpp +++ b/test/test-util.hpp @@ -10,6 +10,9 @@ namespace WebStat { #define XSTR(s) STR(s) #define STR(s) #s inline const std::filesystem::path SRC_DIR(XSTR(SRC)); + inline const std::filesystem::path TEST_DIR(XSTR(TEST)); + inline const std::filesystem::path FIXTURE_DIR(XSTR(FIXTURES)); + inline const std::string FIXTURE_URL_BASE = "file://" + std::filesystem::canonical(FIXTURE_DIR).string(); #undef XSTR #undef STR |