void SetUp() {
init();
}
- void doInInit() {
+ ElementPtr buildConfig(const string& config) const {
+ const ElementPtr internal(Element::fromJSON(config));
+ const ElementPtr external(Element::fromJSON("{\"version\": 1}"));
+ external->set("classes", internal);
+ return (external);
+ }
+ void initializeINList() {
const ElementPtr
- config(Element::fromJSON("{\"IN\": [{\"type\": \"xxx\"}]}"));
+ config(buildConfig("{\"IN\": [{\"type\": \"xxx\"}]}"));
session.addMessage(createCommand("config_update", config), "data_sources",
"*");
mccs->checkCommand();
TEST_F(DatasrcConfiguratorTest, modifyList) {
// First, initialize the list
- doInInit();
+ initializeINList();
// And now change the configuration of the list
const ElementPtr
- config(Element::fromJSON("{\"IN\": [{\"type\": \"yyy\"}]}"));
+ config(buildConfig("{\"IN\": [{\"type\": \"yyy\"}]}"));
session.addMessage(createCommand("config_update", config), "data_sources",
"*");
log_ = "";
// It's almost like above, but we initialize first with single-list
// config.
TEST_F(DatasrcConfiguratorTest, updateAdd) {
- doInInit();
+ initializeINList();
const ElementPtr
- config(Element::fromJSON("{\"IN\": [{\"type\": \"yyy\"}], "
- "\"CH\": [{\"type\": \"xxx\"}]}"));
+ config(buildConfig("{\"IN\": [{\"type\": \"yyy\"}], "
+ "\"CH\": [{\"type\": \"xxx\"}]}"));
session.addMessage(createCommand("config_update", config), "data_sources",
"*");
log_ = "";
// We delete a class list in this test.
TEST_F(DatasrcConfiguratorTest, updateDelete) {
- doInInit();
+ initializeINList();
const ElementPtr
- config(Element::fromJSON("{}"));
+ config(buildConfig("{}"));
session.addMessage(createCommand("config_update", config), "data_sources",
"*");
log_ = "";
// Check that we can rollback an addition if something else fails
TEST_F(DatasrcConfiguratorTest, rollbackAddition) {
- doInInit();
+ initializeINList();
// The configuration is wrong. However, the CH one will get done first.
const ElementPtr
- config(Element::fromJSON("{\"IN\": [{\"type\": 13}], "
- "\"CH\": [{\"type\": \"xxx\"}]}"));
+ config(buildConfig("{\"IN\": [{\"type\": 13}], "
+ "\"CH\": [{\"type\": \"xxx\"}]}"));
session.addMessage(createCommand("config_update", config), "data_sources",
"*");
log_ = "";