Backing storage for dynamic_config::Source
in tests and benchmarks.
More...
#include <userver/dynamic_config/storage_mock.hpp>
Backing storage for dynamic_config::Source
in tests and benchmarks.
- Warning
- Make sure that
StorageMock
outlives all the acquired pointers! class DummyClient;
return config[kDummyConfig].bar;
}
UTEST(DynamicConfig, Snippet) {
{kDummyConfig, {42, "what"}},
{kIntConfig, 5},
};
EXPECT_EQ(DummyFunction(storage.GetSnapshot()), "what");
DummyClient client{storage.GetSource()};
storage.Extend({{kDummyConfig, {-10000, "invalid"}}});
}
UTEST(DynamicConfig, FromJson) {
{kDummyConfig, kJson},
{kIntConfig, 5},
};
const auto config = storage.GetSnapshot();
EXPECT_EQ(config[kDummyConfig].foo, 42);
EXPECT_EQ(config[kDummyConfig].bar, "what");
EXPECT_EQ(config[kIntConfig], 5);
}
- See also
- dynamic_config::GetDefaultSource
-
dynamic_config::MakeDefaultStorage
Definition at line 59 of file storage_mock.hpp.
◆ StorageMock() [1/2]
dynamic_config::StorageMock::StorageMock |
( |
std::initializer_list< KeyValue > |
config_variables | ) |
|
Only store config_variables
in the Config
. Use as: StorageMock{{kVariableKey1, value1}, {kVariableKey2, value2}}
◆ StorageMock() [2/2]
dynamic_config::StorageMock::StorageMock |
( |
const DocsMap & |
defaults, |
|
|
const std::vector< KeyValue > & |
overrides |
|
) |
| |
Store overrides
in the Config
, then parse all the remaining variables from defaults
- See also
- dynamic_config::MakeDefaultStorage
The documentation for this class was generated from the following file: