summaryrefslogtreecommitdiff
path: root/test/test-ingest.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan.goodliffe@octal.co.uk>2025-10-09 15:48:28 +0100
committerDan Goodliffe <dan.goodliffe@octal.co.uk>2025-10-09 15:48:28 +0100
commit1a9440ec3c1669c5e49825dde70b9cbede3f0de0 (patch)
tree20269be529b17fb578fa305d7603cc3badf7c003 /test/test-ingest.cpp
parenta7a082d8d471bc38f9aa1160b0e9f8daf3d35ba3 (diff)
downloadwebstat-1a9440ec3c1669c5e49825dde70b9cbede3f0de0.tar.bz2
webstat-1a9440ec3c1669c5e49825dde70b9cbede3f0de0.tar.xz
webstat-1a9440ec3c1669c5e49825dde70b9cbede3f0de0.zip
Fix premature remembering of saved entity idswebstat-0.2.1
Don't persist entity ids saved to the DB until the transaction is committed. Prevents the issue where a later DB operation fails, the transaction is rolled back, but we still think the entity has been saved.
Diffstat (limited to 'test/test-ingest.cpp')
-rw-r--r--test/test-ingest.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/test/test-ingest.cpp b/test/test-ingest.cpp
index 9e401b3..9534a9f 100644
--- a/test/test-ingest.cpp
+++ b/test/test-ingest.cpp
@@ -231,6 +231,7 @@ BOOST_DATA_TEST_CASE(StoreLogLine,
BOOST_CHECK_EQUAL(linesRead, 0);
BOOST_CHECK_EQUAL(linesParsed, 1);
BOOST_CHECK_EQUAL(linesDiscarded, 0);
+ BOOST_CHECK_EQUAL(existingEntities.size(), 4);
}
BOOST_AUTO_TEST_CASE(StoreLog, *boost::unit_test::depends_on("I/StoreLogLine"))
@@ -258,9 +259,12 @@ BOOST_TEST_DECORATOR(*boost::unit_test::depends_on("I/ParkLogLine"))
BOOST_AUTO_TEST_CASE(ParkLogLineOnError)
{
- BOOST_REQUIRE_NO_THROW(dbpool->get()->execute("SET search_path = ''"));
- BOOST_REQUIRE_NO_THROW(ingestLogLine(LOGLINE1));
+ BOOST_REQUIRE(existingEntities.empty());
+ constexpr std::string_view LOGLINE_BAD_VERB
+ = R"LOG(git.randomdan.homeip.net 98.82.40.168 1755561576768318 CAUSEPARK "/repo/gentoobrowse-api/commit/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/app-crypt/pdfcrack/Manifest" "?h=gentoobrowse-api-0.9.1&id=a2ed3fd30333721accd4b697bfcb6cc4165c7714" HTTP/1.1 200 1884 107791 "-" "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; Amazonbot/0.1; +https://developer.amazon.com/support/amazonbot) Chrome/119.0.6045.214 Safari/537.36")LOG";
+ BOOST_REQUIRE_NO_THROW(ingestLogLine(LOGLINE_BAD_VERB));
BOOST_CHECK_EQUAL(linesParked, 1);
+ BOOST_CHECK(existingEntities.empty());
}
BOOST_AUTO_TEST_CASE(IngestParked, *boost::unit_test::depends_on("I/ParkLogLine"))