mgmt: ndns-add-rr-from-file update RR to the latest version

Change-Id: Ia6812e5961bdc885e92cd49fafe2298390667040
Refs: #2259
diff --git a/tests/unit/mgmt/management-tool.cpp b/tests/unit/mgmt/management-tool.cpp
index 3f18807..f5137e1 100644
--- a/tests/unit/mgmt/management-tool.cpp
+++ b/tests/unit/mgmt/management-tool.cpp
@@ -656,12 +656,11 @@
 
 BOOST_FIXTURE_TEST_CASE(AddRrSet6, ManagementToolFixture)
 {
-  //check using user provided certificate
+  //check invalid output
   Name parentZoneName("/ndns-test");
   Name zoneName = Name(parentZoneName).append("child-zone");
   m_tool.createZone(zoneName, parentZoneName);
 
-  //check invalid output
   Name content = "invalid data packet";
   std::string output = TEST_CERTDIR.string() + "/ss.cert";
   ndn::io::save(content, output);
@@ -669,6 +668,40 @@
   BOOST_CHECK_THROW(m_tool.addRrSet(zoneName, output), ndns::ManagementTool::Error);
 }
 
+BOOST_FIXTURE_TEST_CASE(AddRrSet7, ManagementToolFixture)
+{
+  //check version control
+  Name parentZoneName("/ndns-test");
+  Name zoneName = Name(parentZoneName).append("child-zone");
+  m_tool.createZone(zoneName, parentZoneName);
+
+  Name label("/label");
+  uint64_t version = 110;
+
+  m_tool.addRrSet(zoneName, label, label::NS_RR_TYPE, NDNS_RESP, version);
+  // throw error when adding duplicated rrset with the same version
+  BOOST_CHECK_THROW(m_tool.addRrSet(zoneName, label, label::NS_RR_TYPE, NDNS_RESP, version),
+                    ndns::ManagementTool::Error);
+  version--;
+  // throw error when adding duplicated rrset with older version
+  BOOST_CHECK_THROW(m_tool.addRrSet(zoneName, label, label::NS_RR_TYPE, NDNS_RESP, version),
+                    ndns::ManagementTool::Error);
+
+  version++;
+  version++;
+  BOOST_CHECK_NO_THROW(m_tool.addRrSet(zoneName, label, label::NS_RR_TYPE, NDNS_RESP, version));
+
+  Zone zone(zoneName);
+  m_dbMgr.find(zone);
+  Rrset rrset;
+  rrset.setZone(&zone);
+  rrset.setLabel(label);
+  rrset.setType(label::NS_RR_TYPE);
+  m_dbMgr.find(rrset);
+
+  BOOST_CHECK_EQUAL(rrset.getVersion(), name::Component::fromVersion(version));
+}
+
 BOOST_FIXTURE_TEST_CASE(ListAllZones, ManagementToolFixture)
 {
   m_tool.createZone(ROOT_ZONE, ROOT_ZONE, time::seconds(1), time::days(1), rootKsk, rootDsk);