summaryrefslogtreecommitdiff
path: root/test/testing-util.hpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-12-20 15:08:37 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2025-12-20 15:08:37 +0000
commit0b34bd33d9b74e51adccba4b330b0bd264a7d24c (patch)
treeaaef37fc02cbd8b70cadc6ce94e83e85f83c32b8 /test/testing-util.hpp
parent28892f3d4cf6d9fb6486de5197dd6d46da706f13 (diff)
downloadwebstat-0b34bd33d9b74e51adccba4b330b0bd264a7d24c.tar.bz2
webstat-0b34bd33d9b74e51adccba4b330b0bd264a7d24c.tar.xz
webstat-0b34bd33d9b74e51adccba4b330b0bd264a7d24c.zip
Rename test utilities to avoid name conflict.
Diffstat (limited to 'test/testing-util.hpp')
-rw-r--r--test/testing-util.hpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/testing-util.hpp b/test/testing-util.hpp
new file mode 100644
index 0000000..f933cba
--- /dev/null
+++ b/test/testing-util.hpp
@@ -0,0 +1,45 @@
+#pragma once
+
+#include <connectionPool.h>
+#include <filesystem>
+#include <pq-mock.h>
+#include <sys/utsname.h>
+#include <util.hpp>
+
+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
+
+ struct MockDB : public DB::PluginMock<PQ::Mock> {
+ MockDB();
+ };
+
+ class MockDBPool : public DB::BasicConnectionPool {
+ public:
+ MockDBPool(std::string);
+
+ protected:
+ DB::ConnectionPtr createResource() const;
+
+ private:
+ std::string name;
+ };
+
+ template<typename Out> using ParseData = std::tuple<std::string_view, Out>;
+
+ utsname getTestUtsName(std::string_view);
+
+ struct LogFile {
+ LogFile(std::filesystem::path where, size_t entries);
+ ~LogFile();
+ SPECIAL_MEMBERS_DELETE(LogFile);
+
+ const std::filesystem::path path;
+ };
+}