Add dump command

Change-Id: If38d01ebb8788090f91a76daf6b7fc9add0320b7
diff --git a/tests/command_completion.cpp b/tests/command_completion.cpp
index 45eb998..06cedd7 100644
--- a/tests/command_completion.cpp
+++ b/tests/command_completion.cpp
@@ -21,7 +21,7 @@
     int expectedContextLength;
     SECTION("no prefix")
     {
-        expectedCompletions = {"cd", "copy", "create", "delete", "set", "commit", "get", "ls", "discard", "help", "describe", "move"};
+        expectedCompletions = {"cd", "copy", "create", "delete", "set", "commit", "get", "ls", "discard", "help", "describe", "move", "dump"};
         expectedContextLength = 0;
         SECTION("no space") {
             input = "";
@@ -41,7 +41,7 @@
     SECTION("d")
     {
         input = "d";
-        expectedCompletions = {"delete", "discard", "describe"};
+        expectedCompletions = {"delete", "discard", "describe", "dump"};
         expectedContextLength = 1;
     }
 
diff --git a/tests/datastore_access.cpp b/tests/datastore_access.cpp
index 57ecf24..e505851 100644
--- a/tests/datastore_access.cpp
+++ b/tests/datastore_access.cpp
@@ -97,7 +97,7 @@
     {
         {
             std::ofstream of(testConfigFile);
-            of << dumpXML();
+            of << dump(DataFormat::Xml);
         }
         auto command = std::string(sysrepocfgExecutable) + " --import=" + testConfigFile + " --format=xml --datastore=running example-schema";
         REQUIRE(std::system(command.c_str()) == 0);
@@ -218,9 +218,11 @@
 
     SECTION("create presence container")
     {
+        REQUIRE(datastore.dump(DataFormat::Json).find("example-schema:pContainer") == std::string::npos);
         REQUIRE_CALL(mock, write("/example-schema:pContainer", std::nullopt, ""s));
         datastore.createItem("/example-schema:pContainer");
         datastore.commitChanges();
+        REQUIRE(datastore.dump(DataFormat::Json).find("example-schema:pContainer") != std::string::npos);
     }
 
     SECTION("create/delete a list instance")
@@ -813,6 +815,16 @@
         datastore.deleteItem("/example-schema:leafInt32");
     }
 
+    SECTION("two key lists")
+    {
+        REQUIRE_CALL(mock, write("/example-schema:point[x='12'][y='10']", std::nullopt, ""s));
+        REQUIRE_CALL(mock, write("/example-schema:point[x='12'][y='10']/x", std::nullopt, "12"s));
+        REQUIRE_CALL(mock, write("/example-schema:point[x='12'][y='10']/y", std::nullopt, "10"s));
+        datastore.createItem("/example-schema:point[x='12'][y='10']");
+        datastore.commitChanges();
+        REQUIRE(datastore.dump(DataFormat::Json).find("example-schema:point") != std::string::npos);
+    }
+
     waitForCompletionAndBitMore(seq1);
 }
 
diff --git a/tests/datastoreaccess_mock.hpp b/tests/datastoreaccess_mock.hpp
index a495b99..e1d365b 100644
--- a/tests/datastoreaccess_mock.hpp
+++ b/tests/datastoreaccess_mock.hpp
@@ -35,6 +35,7 @@
     IMPLEMENT_MOCK0(commitChanges);
     IMPLEMENT_MOCK0(discardChanges);
     IMPLEMENT_MOCK2(copyConfig);
+    IMPLEMENT_CONST_MOCK1(dump);
 };
 
 
diff --git a/tests/example-schema.yang b/tests/example-schema.yang
index fdd8daf..792ac42 100644
--- a/tests/example-schema.yang
+++ b/tests/example-schema.yang
@@ -264,4 +264,14 @@
             type string;
         }
     }
+
+    list point {
+        key "x y";
+        leaf x {
+            type int32;
+        }
+        leaf y {
+            type int32;
+        }
+    }
 }