blob: afde3d3ec725b82ec62852ad1e412e48df607003 (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#include <string>
#include <stack>
#include <memory>
#include <gtest/gtest.h>
#include "common/config_fwd.h"
class ObjectStore;
class StoreTestFixture : virtual public ::testing::Test {
const std::string type;
std::stack<std::pair<std::string, std::string>> saved_settings;
ConfigProxy* conf = nullptr;
protected:
const std::string data_dir;
public:
std::unique_ptr<ObjectStore> store;
ObjectStore::CollectionHandle ch;
explicit StoreTestFixture(const std::string& type)
: type(type), data_dir(type + ".test_temp_dir")
{}
void SetUp() override;
void TearDown() override;
void SetVal(ConfigProxy& conf, const char* key, const char* val);
struct SettingsBookmark {
StoreTestFixture& s;
size_t pos;
SettingsBookmark(StoreTestFixture& _s, size_t p) : s(_s), pos(p)
{}
~SettingsBookmark() {
s.PopSettings(pos);
}
};
SettingsBookmark BookmarkSettings() {
return SettingsBookmark(*this, saved_settings.size());
}
void PopSettings(size_t);
void CloseAndReopen();
void RemoveTestObjectStore();
const std::string get_type() const {
return type;
}
const std::string get_data_dir() const {
return data_dir;
}
};
|