summaryrefslogtreecommitdiff
path: root/test/test-util.hpp
blob: b0ae0dd4abe04e0deef4be0a68d5ad3d134c5e36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#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));
#undef XSTR
#undef STR

	using FilePtr = std::unique_ptr<std::FILE, DeleteWith<&fclose>>;

	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);
}