diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-08-23 15:34:51 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2025-08-25 16:01:17 +0100 |
commit | d0fe9fe6c613ec8894ca4b1d330e7847845a4710 (patch) | |
tree | 60abb970345fcb9e8808c7aee3134bd976775071 /test | |
parent | faff88728dc925a08515f96236cab62bb70110e5 (diff) | |
download | webstat-d0fe9fe6c613ec8894ca4b1d330e7847845a4710.tar.bz2 webstat-d0fe9fe6c613ec8894ca4b1d330e7847845a4710.tar.xz webstat-d0fe9fe6c613ec8894ca4b1d330e7847845a4710.zip |
Add DB schema and setup a mock of it in testing
Diffstat (limited to 'test')
-rw-r--r-- | test/Jamfile.jam | 6 | ||||
-rw-r--r-- | test/test-ingest.cpp | 17 |
2 files changed, 23 insertions, 0 deletions
diff --git a/test/Jamfile.jam b/test/Jamfile.jam index a008606..8460cef 100644 --- a/test/Jamfile.jam +++ b/test/Jamfile.jam @@ -1,14 +1,20 @@ lib boost_unit_test_framework : : <link>shared ; +lib dbpptestcore : : <link>shared ; +lib stdc++fs ; path-constant src : ../src ; path-constant test : . ; run test-ingest.cpp : -- : + ../src/schema.sql : <define>BOOST_TEST_DYN_LINK <define>SRC=\"$(src)\" <define>TEST=\"$(test)\" <library>$(src)//webstat + <library>..//dbpp-postgresql <library>boost_unit_test_framework + <library>dbpptestcore + <library>stdc++fs ; diff --git a/test/test-ingest.cpp b/test/test-ingest.cpp index 0bbeeae..af063f3 100644 --- a/test/test-ingest.cpp +++ b/test/test-ingest.cpp @@ -2,7 +2,24 @@ #include <boost/test/data/test_case.hpp> #include <boost/test/unit_test.hpp> +#include <dbpp-postgresql/pq-mock.h> +#include <filesystem> #include <ingestor.hpp> +#include <mockDatabase.h> + +#define XSTR(s) STR(s) +#define STR(s) #s +const std::filesystem::path SRC_DIR(XSTR(SRC)); +const std::filesystem::path TEST_DIR(XSTR(TEST)); +#undef XSTR +#undef STR + +class Mock : public DB::PluginMock<PQ::Mock> { +public: + Mock() : DB::PluginMock<PQ::Mock>("webstat", {SRC_DIR / "schema.sql"}, "user=postgres dbname=postgres") { } +}; + +BOOST_GLOBAL_FIXTURE(Mock); using ScanValues = std::remove_cvref_t<decltype(std::declval<WebStat::Ingestor::ScanResult>()->values())>; template<typename Out> using ParseData = std::tuple<std::string_view, Out>; |