Merge changes I200f8ccf,Ia4ae1ed3
* changes:
Make NetconfAccess:getItems consistent with lists
Rename test
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1dd95a3..27172a5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -278,8 +278,8 @@
target_link_libraries(test_path_utils path)
setup_datastore_tests()
- datastore_test(setting_values ${CMAKE_CURRENT_SOURCE_DIR}/example-schema.yang)
- set_tests_properties(kill_daemons PROPERTIES DEPENDS test_setting_values_netconf_cleanup)
+ datastore_test(datastore_access ${CMAKE_CURRENT_SOURCE_DIR}/example-schema.yang)
+ set_tests_properties(kill_daemons PROPERTIES DEPENDS test_datastore_access_netconf_cleanup)
endif()
diff --git a/src/netconf_access.cpp b/src/netconf_access.cpp
index e53237b..d1619cb 100644
--- a/src/netconf_access.cpp
+++ b/src/netconf_access.cpp
@@ -57,6 +57,9 @@
for (const auto& it : items) {
if (!it)
continue;
+ if (it->schema()->nodetype() == LYS_LIST) {
+ res.emplace(it->path(), std::string{"(list)"});
+ }
if (it->schema()->nodetype() == LYS_LEAF) {
libyang::Data_Node_Leaf_List leaf(it);
res.emplace(leaf.path(), leafValueFromValue(leaf.value(), leaf.leaf_type()->base()));
diff --git a/tests/setting_values.cpp b/tests/datastore_access.cpp
similarity index 84%
rename from tests/setting_values.cpp
rename to tests/datastore_access.cpp
index d15e2dc..09801b2 100644
--- a/tests/setting_values.cpp
+++ b/tests/datastore_access.cpp
@@ -225,5 +225,31 @@
REQUIRE(datastore.getItems("/example-schema:leafEnum") == expected);
}
+ SECTION("getItems on a list")
+ {
+ {
+ REQUIRE_CALL(mock, write("/example-schema:person[name='Jan']", "", ""));
+ REQUIRE_CALL(mock, write("/example-schema:person[name='Jan']/name", "", "Jan"));
+ REQUIRE_CALL(mock, write("/example-schema:person[name='Michal']", "", ""));
+ REQUIRE_CALL(mock, write("/example-schema:person[name='Michal']/name", "", "Michal"));
+ REQUIRE_CALL(mock, write("/example-schema:person[name='Petr']", "", ""));
+ REQUIRE_CALL(mock, write("/example-schema:person[name='Petr']/name", "", "Petr"));
+ datastore.createListInstance("/example-schema:person[name='Jan']");
+ datastore.createListInstance("/example-schema:person[name='Michal']");
+ datastore.createListInstance("/example-schema:person[name='Petr']");
+ datastore.commitChanges();
+ }
+ std::map<std::string, leaf_data_> expected{
+ {"/example-schema:person[name='Jan']", std::string{"(list)"}},
+ {"/example-schema:person[name='Jan']/name", std::string{"Jan"}},
+ {"/example-schema:person[name='Michal']", std::string{"(list)"}},
+ {"/example-schema:person[name='Michal']/name", std::string{"Michal"}},
+ {"/example-schema:person[name='Petr']", std::string{"(list)"}},
+ {"/example-schema:person[name='Petr']/name", std::string{"Petr"}}
+ };
+
+ REQUIRE(datastore.getItems("/example-schema:person") == expected);
+ }
+
waitForCompletionAndBitMore(seq1);
}