Browse Source

[5114] Minor test improvements after review

Tomek Mrugalski 8 years ago
parent
commit
567fdab06c

+ 1 - 1
src/bin/dhcp6/tests/config_parser_unittest.cc

@@ -1165,7 +1165,7 @@ TEST_F(Dhcp6ParserTest, subnetLocal) {
 TEST_F(Dhcp6ParserTest, subnetInterface) {
 
     // There should be at least one interface
-
+    // As far as I can tell, this is the first lambda in Kea code. Cool.
     auto config = [this](string iface) {
         return ("{ " + genIfaceConfig() + ","
                 "\"preferred-lifetime\": 3000,"

+ 1 - 15
src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc

@@ -703,21 +703,7 @@ public:
     void runCfgOptionsTest(uint16_t family, std::string config) {
         ConstElementPtr json;
         ASSERT_NO_THROW(json = Element::fromJSON(config)) << config;
-        ConstElementPtr option_def = json->get("option-def");
-        if (option_def) {
-            SimpleParser::setListDefaults(option_def,
-                                          family == AF_INET ?
-                                          ParseConfigTest::OPTION4_DEF_DEFAULTS :
-                                          ParseConfigTest::OPTION6_DEF_DEFAULTS);
-        }
-        ConstElementPtr option_data = json->get("option-data");
-        if (option_data) {
-            SimpleParser::setListDefaults(option_data,
-                                          family == AF_INET ?
-                                          ParseConfigTest::OPTION4_DEFAULTS :
-                                          ParseConfigTest::OPTION6_DEFAULTS);
-        }
-        runToElementTest<CfgOptionsTest>(json, *this);
+        runCfgOptionsTest(family, json);
     }
 
 private:

+ 1 - 2
src/lib/dhcpsrv/tests/host_reservation_parser_unittest.cc

@@ -356,7 +356,7 @@ TEST_F(HostReservationParserTest, dhcp4ClientIdHexWithPrefix) {
 // This test verifies that the parser can parse the reservation entry
 // when IPv4 address is specified, but hostname is not.
 TEST_F(HostReservationParserTest, dhcp4NoHostname) {
-    std::string config = "{ \"duid\": \"01:02:03:04:05:06:07:08:09:0A\","
+    std::string config = "{ \"duid\": \"01:02:03:04:05:06:07:08:09:0a\","
         "\"ip-address\": \"192.0.2.10\" }";
 
     ElementPtr config_element = Element::fromJSON(config);
@@ -376,7 +376,6 @@ TEST_F(HostReservationParserTest, dhcp4NoHostname) {
     EXPECT_TRUE(hosts[0]->getHostname().empty());
 
     // lower duid value
-    boost::algorithm::to_lower(config);
     CfgMgr::instance().setFamily(AF_INET);
     CfgHostsSubnet cfg_subnet(cfg_hosts, SubnetID(10));
     runToElementTest<CfgHostsSubnet>("[" + config + "]", cfg_subnet);

+ 4 - 0
src/lib/dhcpsrv/tests/ifaces_config_parser_unittest.cc

@@ -60,6 +60,7 @@ TEST_F(IfacesConfigParserTest, interfaces) {
     // Parse the configuration.
     IfacesConfigParser parser(AF_INET);
     CfgIfacePtr cfg_iface = CfgMgr::instance().getStagingCfg()->getCfgIface();
+    ASSERT_TRUE(cfg_iface);
     ASSERT_NO_THROW(parser.parse(cfg_iface, config_element));
 
     // Check it can be unparsed.
@@ -84,6 +85,7 @@ TEST_F(IfacesConfigParserTest, interfaces) {
     config_element = Element::fromJSON(config);
 
     cfg_iface = CfgMgr::instance().getStagingCfg()->getCfgIface();
+    ASSERT_TRUE(cfg_iface);
     ASSERT_NO_THROW(parser.parse(cfg_iface, config_element));
 
     runToElementTest<CfgIface>(config, *cfg_iface);
@@ -137,6 +139,7 @@ TEST_F(IfacesConfigParserTest, socketTypeDatagram) {
     // Parse the configuration.
     IfacesConfigParser parser(AF_INET);
     CfgIfacePtr cfg_iface = CfgMgr::instance().getStagingCfg()->getCfgIface();
+    ASSERT_TRUE(cfg_iface);
     ASSERT_NO_THROW(parser.parse(cfg_iface, config_element));
 
     // Check it can be unparsed.
@@ -147,6 +150,7 @@ TEST_F(IfacesConfigParserTest, socketTypeDatagram) {
     SrvConfigPtr cfg = CfgMgr::instance().getStagingCfg();
     ASSERT_TRUE(cfg);
     cfg_ref.useSocketType(AF_INET, CfgIface::SOCKET_UDP);
+    ASSERT_TRUE(cfg->getCfgIface());
     EXPECT_TRUE(*cfg->getCfgIface() == cfg_ref);
 }