From: Michal 'vorner' Vaner Date: Thu, 21 Jun 2012 09:51:37 +0000 (+0200) Subject: [1976] Tests for reconfiguration and multiple lists X-Git-Tag: trac2351_base~97^2~7^2~2^2~21^2~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9d269c5437c03247628e8d73ebda85a2e1e7ef72;p=thirdparty%2Fkea.git [1976] Tests for reconfiguration and multiple lists It works all by itself --- diff --git a/src/bin/auth/tests/datasrc_configurator_unittest.cc b/src/bin/auth/tests/datasrc_configurator_unittest.cc index 0926cc1401..d1f0383018 100644 --- a/src/bin/auth/tests/datasrc_configurator_unittest.cc +++ b/src/bin/auth/tests/datasrc_configurator_unittest.cc @@ -98,6 +98,16 @@ protected: void SetUp() { init(); } + void doInInit() { + const ElementPtr + config(Element::fromJSON("{\"IN\": [{\"type\": \"xxx\"}]}")); + session.addMessage(createCommand("config_update", config), "data_sources", + "*"); + mccs->checkCommand(); + // Check it called the correct things (check that there's no IN yet and + // set a new one. + EXPECT_EQ("get IN\nset IN xxx\n", log_); + } FakeSession session; auto_ptr mccs; const string specfile; @@ -125,14 +135,39 @@ TEST_F(DatasrcConfiguratorTest, initialization) { // Push there a configuration with a single list. TEST_F(DatasrcConfiguratorTest, createList) { + doInInit(); +} + +TEST_F(DatasrcConfiguratorTest, modifyList) { + // First, initialize the list + doInInit(); + // And now change the configuration of the list + const ElementPtr + config(Element::fromJSON("{\"IN\": [{\"type\": \"yyy\"}]}")); + session.addMessage(createCommand("config_update", config), "data_sources", + "*"); + log_ = ""; + mccs->checkCommand(); + // This one does not set + EXPECT_EQ("get IN\n", log_); + // But this should contain the yyy configuration + EXPECT_EQ("yyy", lists_[RRClass::IN()]->getConf()); +} + +// Check we can have multiple lists at once +TEST_F(DatasrcConfiguratorTest, multiple) { const ElementPtr - config(Element::fromJSON("{\"IN\": [{\"type\": \"xxx\"}]}")); + config(Element::fromJSON("{\"IN\": [{\"type\": \"yyy\"}], " + "\"CH\": [{\"type\": \"xxx\"}]}")); session.addMessage(createCommand("config_update", config), "data_sources", "*"); mccs->checkCommand(); - // Check it called the correct things (check that there's no IN yet and - // set a new one. - EXPECT_EQ("get IN\nset IN xxx\n", log_); + // This one does not set + EXPECT_EQ("get CH\nset CH xxx\nget IN\nset IN yyy\n", log_); + // We should have both there + EXPECT_EQ("yyy", lists_[RRClass::IN()]->getConf()); + EXPECT_EQ("xxx", lists_[RRClass::CH()]->getConf()); + EXPECT_EQ(2, lists_.size()); } }