]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#440,!218] Addressed review comments. 441-make-distcheck-fails-on-fedora-29_base
authorMarcin Siodelski <marcin@isc.org>
Tue, 5 Feb 2019 08:50:11 +0000 (09:50 +0100)
committerMarcin Siodelski <marcin@isc.org>
Tue, 5 Feb 2019 08:50:11 +0000 (09:50 +0100)
src/hooks/dhcp/mysql_cb/mysql_cb_dhcp4.cc
src/hooks/dhcp/mysql_cb/tests/mysql_cb_dhcp4_unittest.cc

index d0a10910a1c5187e4ee17012d845734a0c31f6ba..daf48c1aa181ef17c8ff5abf0e51ea74965be1a2 100644 (file)
@@ -757,8 +757,7 @@ public:
         subnet->getSharedNetwork(shared_network);
 
         // Check if the subnet is associated with a shared network instance.
-        // If it is, create the binding using the name of the shared network
-        // returned by this instance.
+        // If it is, create the binding using the name of the shared network.
         if (shared_network) {
             shared_network_binding = MySqlBinding::createString(shared_network->getName());
 
index a8db9c39077b9b7bf86187b75eccb2d1a0a56c20..eed4f3e696f8c0aad6a0a1145a99fb26d9c46f67 100644 (file)
@@ -803,7 +803,7 @@ TEST_F(MySqlConfigBackendDHCPv4Test, getModifiedSubnets4) {
 
 // Test that subnets belonging to a shared network can be retrieved.
 TEST_F(MySqlConfigBackendDHCPv4Test, getSharedNetworkSubnets4) {
-    // Assign test subnets into shared networks level1 and level2.
+    // Assign test subnets to shared networks level1 and level2.
     test_subnets_[1]->setSharedNetworkName("level1");
     test_subnets_[2]->setSharedNetworkName("level2");
     test_subnets_[3]->setSharedNetworkName("level2");
@@ -824,30 +824,40 @@ TEST_F(MySqlConfigBackendDHCPv4Test, getSharedNetworkSubnets4) {
     ASSERT_EQ(1, subnets.size());
 
     // Returned subnet should match test subnet #1.
-    EXPECT_EQ(test_subnets_[1]->toElement()->str(), subnets[0]->toElement()->str());
+    EXPECT_TRUE(isEquivalent(test_subnets_[1]->toElement(),
+                             subnets[0]->toElement()));
 
     // All subnets should also be returned for explicitly specified server tag.
     subnets = cbptr_->getSharedNetworkSubnets4(ServerSelector::ONE("server1"), "level1");
     ASSERT_EQ(1, subnets.size());
 
     // Returned subnet should match test subnet #1.
-    EXPECT_EQ(test_subnets_[1]->toElement()->str(), subnets[0]->toElement()->str());
+    EXPECT_TRUE(isEquivalent(test_subnets_[1]->toElement(),
+                             subnets[0]->toElement()));
 
     // Fetch all subnets belonging to shared network level2.
     subnets = cbptr_->getSharedNetworkSubnets4(ServerSelector::ALL(), "level2");
     ASSERT_EQ(2, subnets.size());
 
-    // Verify the subnets. It is safe to assume the order in which they have
-    // been returned, because the SELECT statement orders by subnet id.
-    EXPECT_EQ(test_subnets_[2]->toElement()->str(), subnets[0]->toElement()->str());
-    EXPECT_EQ(test_subnets_[3]->toElement()->str(), subnets[1]->toElement()->str());
+    ElementPtr test_list = Element::createList();
+    test_list->add(test_subnets_[2]->toElement());
+    test_list->add(test_subnets_[3]->toElement());
+
+    ElementPtr returned_list = Element::createList();
+    returned_list->add(subnets[0]->toElement());
+    returned_list->add(subnets[1]->toElement());
+
+    EXPECT_TRUE(isEquivalent(returned_list, test_list));
 
     // All subnets should also be returned for explicitly specified server tag.
     subnets = cbptr_->getSharedNetworkSubnets4(ServerSelector::ONE("server1"), "level2");
     ASSERT_EQ(2, subnets.size());
 
-    EXPECT_EQ(test_subnets_[2]->toElement()->str(), subnets[0]->toElement()->str());
-    EXPECT_EQ(test_subnets_[3]->toElement()->str(), subnets[1]->toElement()->str());
+    returned_list = Element::createList();
+    returned_list->add(subnets[0]->toElement());
+    returned_list->add(subnets[1]->toElement());
+
+    EXPECT_TRUE(isEquivalent(returned_list, test_list));
 }
 
 // Test that shared network can be inserted, fetched, updated and then