Fix NetconfAccess::deletePresenceContainer
This method had the same problem as deleteListInstance.
Bug: https://tree.taiga.io/project/jktjkt-netconf-cli/issue/153
Change-Id: I84d6c3323a69156c54c1159b153cdce8a22941c7
diff --git a/tests/datastore_access.cpp b/tests/datastore_access.cpp
index fe7df81..ba52b9c 100644
--- a/tests/datastore_access.cpp
+++ b/tests/datastore_access.cpp
@@ -226,6 +226,7 @@
// results will be consistent.
#ifdef sysrepo_BACKEND
{"/example-schema:lol", special_{SpecialValue::Container}},
+ {"/example-schema:inventory", special_{SpecialValue::Container}},
#endif
{"/example-schema:up", bool{true}}};
REQUIRE(datastore.getItems("/example-schema:*") == expected);
@@ -293,7 +294,31 @@
}
expected = {};
REQUIRE(datastore.getItems("/example-schema:pContainer") == expected);
+ }
+ SECTION("nested presence container")
+ {
+ DatastoreAccess::Tree expected;
+ // Make sure it's not there before we create it
+ REQUIRE(datastore.getItems("/example-schema:inventory/stuff") == expected);
+ {
+ REQUIRE_CALL(mock, write("/example-schema:inventory", std::nullopt, ""s));
+ REQUIRE_CALL(mock, write("/example-schema:inventory/stuff", std::nullopt, ""s));
+ datastore.createPresenceContainer("/example-schema:inventory/stuff");
+ datastore.commitChanges();
+ }
+ expected = {
+ {"/example-schema:inventory/stuff", special_{SpecialValue::PresenceContainer}}
+ };
+ REQUIRE(datastore.getItems("/example-schema:inventory/stuff") == expected);
+ {
+ REQUIRE_CALL(mock, write("/example-schema:inventory", ""s, std::nullopt));
+ REQUIRE_CALL(mock, write("/example-schema:inventory/stuff", ""s, std::nullopt));
+ datastore.deletePresenceContainer("/example-schema:inventory/stuff");
+ datastore.commitChanges();
+ }
+ expected = {};
+ REQUIRE(datastore.getItems("/example-schema:inventory/stuff") == expected);
}
SECTION("floats")
diff --git a/tests/example-schema.yang b/tests/example-schema.yang
index a7ff3d8..cbd5d8d 100644
--- a/tests/example-schema.yang
+++ b/tests/example-schema.yang
@@ -6,6 +6,12 @@
prefix other;
}
+ container inventory {
+ container stuff {
+ presence true;
+ }
+ }
+
leaf leafUInt8 {
type uint8;
}