From: Marcin Siodelski Date: Wed, 24 Aug 2016 10:26:20 +0000 (+0200) Subject: [4323] Addressed review comments. X-Git-Tag: trac4631_base~12^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee4c1c66e40d40fc6c79337a9b11980084f18f05;p=thirdparty%2Fkea.git [4323] Addressed review comments. A couple of minor changes in the host_mgr unit tests. --- diff --git a/src/lib/dhcpsrv/tests/host_mgr_unittest.cc b/src/lib/dhcpsrv/tests/host_mgr_unittest.cc index cd163a98e3..45c127069c 100644 --- a/src/lib/dhcpsrv/tests/host_mgr_unittest.cc +++ b/src/lib/dhcpsrv/tests/host_mgr_unittest.cc @@ -209,9 +209,11 @@ HostMgrTest::testGetAll(BaseHostDataSource& data_source1, // If there non-matching HW address is specified, nothing should be // returned. - ASSERT_TRUE(HostMgr::instance().getAll(Host::IDENT_HWADDR, + hosts = HostMgr::instance().getAll(Host::IDENT_HWADDR, &hwaddrs_[1]->hwaddr_[0], - hwaddrs_[1]->hwaddr_.size()).empty()); + hwaddrs_[1]->hwaddr_.size()); + ASSERT_TRUE(hosts.empty()); + // For the correct HW address, there should be two reservations. hosts = HostMgr::instance().getAll(Host::IDENT_HWADDR, &hwaddrs_[0]->hwaddr_[0], @@ -273,13 +275,16 @@ HostMgrTest::testGetAll4(BaseHostDataSource& data_source1, void HostMgrTest::testGet4(BaseHostDataSource& data_source) { + // Initially, no host should be present. ConstHostPtr host = HostMgr::instance().get4(SubnetID(1), hwaddrs_[0]); ASSERT_FALSE(host); + // Add new host to the database. addHost4(data_source, hwaddrs_[0], SubnetID(1), IOAddress("192.0.2.5")); CfgMgr::instance().commit(); + // Retrieve the host from the database and expect that the parameters match. host = HostMgr::instance().get4(SubnetID(1), Host::IDENT_HWADDR, &hwaddrs_[0]->hwaddr_[0], hwaddrs_[0]->hwaddr_.size()); @@ -290,13 +295,16 @@ HostMgrTest::testGet4(BaseHostDataSource& data_source) { void HostMgrTest::testGet6(BaseHostDataSource& data_source) { + // Initially, no host should be present. ConstHostPtr host = HostMgr::instance().get6(SubnetID(2), duids_[0]); ASSERT_FALSE(host); + // Add new host to the database. addHost6(data_source, duids_[0], SubnetID(2), IOAddress("2001:db8:1::1")); CfgMgr::instance().commit(); + // Retrieve the host from the database and expect that the parameters match. host = HostMgr::instance().get6(SubnetID(2), Host::IDENT_DUID, &duids_[0]->getDuid()[0], duids_[0]->getDuid().size()); @@ -323,7 +331,7 @@ HostMgrTest::testGet6ByPrefix(BaseHostDataSource& data_source1, host = HostMgr::instance().get6(IOAddress("2001:db8:1::"), 64); ASSERT_TRUE(host); EXPECT_TRUE(host->hasReservation(IPv6Resrv(IPv6Resrv::TYPE_PD, - IOAddress("2001:db8:1::"), 64))); + IOAddress("2001:db8:1::"), 64))); // Make sure the first reservation is not retrieved when the prefix // length is incorrect. @@ -334,7 +342,7 @@ HostMgrTest::testGet6ByPrefix(BaseHostDataSource& data_source1, host = HostMgr::instance().get6(IOAddress("2001:db8:1:0:6::"), 72); ASSERT_TRUE(host); EXPECT_TRUE(host->hasReservation(IPv6Resrv(IPv6Resrv::TYPE_PD, - IOAddress("2001:db8:1:0:6::"), 72))); + IOAddress("2001:db8:1:0:6::"), 72))); // Make sure the second reservation is not retrieved when the prefix // length is incorrect.