From e6918187568dbd01842d8d1d2c808ce16a894239 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 21 Apr 2024 13:54:28 +0200 Subject: Adding upstream version 18.2.2. Signed-off-by: Daniel Baumann --- src/test/objectstore/store_test_fixture.h | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/test/objectstore/store_test_fixture.h (limited to 'src/test/objectstore/store_test_fixture.h') diff --git a/src/test/objectstore/store_test_fixture.h b/src/test/objectstore/store_test_fixture.h new file mode 100644 index 000000000..3f25fd493 --- /dev/null +++ b/src/test/objectstore/store_test_fixture.h @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include "common/config_fwd.h" + +class ObjectStore; + +class StoreTestFixture : virtual public ::testing::Test { + const std::string type; + const std::string data_dir; + + std::stack> saved_settings; + ConfigProxy* conf = nullptr; + + std::string orig_death_test_style; + +public: + std::unique_ptr 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 SetDeathTestStyle(const char* new_style) { + if (orig_death_test_style.empty()) { + orig_death_test_style = ::testing::FLAGS_gtest_death_test_style; + } + ::testing::FLAGS_gtest_death_test_style = new_style; + } + + 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(); +}; -- cgit v1.2.3