Allow listing all module nodes with moduleName:*
Change-Id: I1c9d8ace936641db06f38c292655b3c5c5557385
diff --git a/tests/ls.cpp b/tests/ls.cpp
index d56df29..e18cf25 100644
--- a/tests/ls.cpp
+++ b/tests/ls.cpp
@@ -157,6 +157,12 @@
expected.m_path = schemaPath_{Scope::Relative, {schemaNode_(module_{"example"}, list_{"list"}),
schemaNode_(container_{"contInList"})}};
}
+
+ SECTION("ls example:*")
+ {
+ input = "ls example:*";
+ expected.m_path = module_{"example"};
+ }
}
command_ command = parser.parseCommand(input, errorStream);
diff --git a/tests/parser_methods.cpp b/tests/parser_methods.cpp
index d8080b3..57e6e56 100644
--- a/tests/parser_methods.cpp
+++ b/tests/parser_methods.cpp
@@ -44,7 +44,7 @@
SECTION("availableNodes")
{
std::set<std::string> expected;
- boost::optional<boost::variant<dataPath_, schemaPath_>> arg{boost::none};
+ boost::optional<boost::variant<boost::variant<dataPath_, schemaPath_>, module_>> arg{boost::none};
SECTION("cwd: /")
{
SECTION("arg: <none>")
diff --git a/tests/sysrepo.cpp b/tests/sysrepo.cpp
index 7125a9a..9c04bf9 100644
--- a/tests/sysrepo.cpp
+++ b/tests/sysrepo.cpp
@@ -187,5 +187,31 @@
REQUIRE(datastore.getItems("/example-schema:down") == expected);
}
+ SECTION("getting items from the whole module")
+ {
+ {
+ REQUIRE_CALL(mock, write("/example-schema:up", "", "true"));
+ REQUIRE_CALL(mock, write("/example-schema:down", "", "false"));
+ datastore.setLeaf("/example-schema:up", bool{true});
+ datastore.setLeaf("/example-schema:down", bool{false});
+ datastore.commitChanges();
+ }
+
+ std::map<std::string, leaf_data_> expected{{"/example-schema:down", bool{false}},
+ // Sysrepo always returns containers when getting values, but
+ // libnetconf does not. This is fine by the YANG standard:
+ // https://tools.ietf.org/html/rfc7950#section-7.5.7 Furthermore,
+ // NetconfAccess implementation actually only iterates over leafs,
+ // so even if libnetconf did include containers, they wouldn't get
+ // shown here anyway. With sysrepo2, this won't be necessary,
+ // because it'll use the same data structure as libnetconf, so the
+ // results will be consistent.
+#ifdef sysrepo_BACKEND
+ {"/example-schema:lol", std::string{"(container)"}},
+#endif
+ {"/example-schema:up", bool{true}}};
+ REQUIRE(datastore.getItems("/example-schema:*") == expected);
+ }
+
waitForCompletionAndBitMore(seq1);
}