diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-09-09 23:24:35 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-09-09 23:24:35 +0100 |
commit | 2eb8897706128f3590a5b4f9ee8f3e755b74f097 (patch) | |
tree | 818290b3be9525ce20c16c8489a225b2fa634259 /test/test-ingest.cpp | |
parent | bdaa314b7eacc7cd41dbf09f8f8ea6d742c3ea37 (diff) | |
download | webstat-2eb8897706128f3590a5b4f9ee8f3e755b74f097.tar.bz2 webstat-2eb8897706128f3590a5b4f9ee8f3e755b74f097.tar.xz webstat-2eb8897706128f3590a5b4f9ee8f3e755b74f097.zip |
Add test over mocked user agent fetch
Uses a file:// URL to curl fetch a local fixture.
Diffstat (limited to 'test/test-ingest.cpp')
-rw-r--r-- | test/test-ingest.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
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( |