Add copy command
Change-Id: I0a88f7fa9a096022dd95e8af8854f980ca34f043
diff --git a/tests/command_completion.cpp b/tests/command_completion.cpp
index eb4949a..607b8ab 100644
--- a/tests/command_completion.cpp
+++ b/tests/command_completion.cpp
@@ -22,21 +22,21 @@
SECTION("")
{
input = "";
- expectedCompletions = {"cd", "create", "delete", "set", "commit", "get", "ls", "discard", "help", "describe"};
+ expectedCompletions = {"cd", "copy", "create", "delete", "set", "commit", "get", "ls", "discard", "help", "describe"};
expectedContextLength = 0;
}
SECTION(" ")
{
input = " ";
- expectedCompletions = {"cd", "create", "delete", "set", "commit", "get", "ls", "discard", "help", "describe"};
+ expectedCompletions = {"cd", "copy", "create", "delete", "set", "commit", "get", "ls", "discard", "help", "describe"};
expectedContextLength = 0;
}
SECTION("c")
{
input = "c";
- expectedCompletions = {"cd", "commit", "create"};
+ expectedCompletions = {"cd", "commit", "copy", "create"};
expectedContextLength = 1;
}
@@ -68,5 +68,12 @@
expectedContextLength = 6;
}
+ SECTION("copy datastores")
+ {
+ input = "copy ";
+ expectedCompletions = {"running", "startup"};
+ expectedContextLength = 0;
+ }
+
REQUIRE(parser.completeCommand(input, errorStream) == (Completions{expectedCompletions, expectedContextLength}));
}
diff --git a/tests/datastore_access.cpp b/tests/datastore_access.cpp
index a6cadc3..a1f9322 100644
--- a/tests/datastore_access.cpp
+++ b/tests/datastore_access.cpp
@@ -336,6 +336,20 @@
}
+ SECTION("copying data from startup refreshes the data")
+ {
+ {
+ REQUIRE(datastore.getItems("/example-schema:leafInt16") == DatastoreAccess::Tree{});
+ REQUIRE_CALL(mock, write("/example-schema:leafInt16", std::nullopt, "123"s));
+ datastore.setLeaf("/example-schema:leafInt16", int16_t{123});
+ datastore.commitChanges();
+ }
+ REQUIRE(datastore.getItems("/example-schema:leafInt16") == DatastoreAccess::Tree{{"/example-schema:leafInt16", int16_t{123}}});
+ REQUIRE_CALL(mock, write("/example-schema:leafInt16", "123"s, std::nullopt));
+ datastore.copyConfig(Datastore::Startup, Datastore::Running);
+ REQUIRE(datastore.getItems("/example-schema:leafInt16") == DatastoreAccess::Tree{});
+ }
+
waitForCompletionAndBitMore(seq1);
}
diff --git a/tests/datastoreaccess_mock.hpp b/tests/datastoreaccess_mock.hpp
index e9dc870..8798973 100644
--- a/tests/datastoreaccess_mock.hpp
+++ b/tests/datastoreaccess_mock.hpp
@@ -35,6 +35,7 @@
IMPLEMENT_MOCK0(commitChanges);
IMPLEMENT_MOCK0(discardChanges);
+ IMPLEMENT_MOCK2(copyConfig);
};