Fix identityref passing through sysrepo and NETCONF
Change-Id: Ie0f712befe56c2fcea52401a12c33812b7fb9066
diff --git a/tests/datastore_access.cpp b/tests/datastore_access.cpp
index 6979dba..a1c8906 100644
--- a/tests/datastore_access.cpp
+++ b/tests/datastore_access.cpp
@@ -330,6 +330,24 @@
REQUIRE(datastore.getItems("/example-schema:unionIntString") == expected);
}
+ SECTION("identityref") {
+ datastore.setLeaf("/example-schema:beast", identityRef_{"example-schema", "Mammal"});
+ REQUIRE_CALL(mock, write("/example-schema:beast", std::nullopt, "example-schema:Mammal"s));
+ datastore.commitChanges();
+ DatastoreAccess::Tree expected {
+ {"/example-schema:beast", identityRef_{"example-schema", "Mammal"}},
+ };
+ REQUIRE(datastore.getItems("/example-schema:beast") == expected);
+
+ datastore.setLeaf("/example-schema:beast", identityRef_{"Whale"});
+ REQUIRE_CALL(mock, write("/example-schema:beast", "example-schema:Mammal", "example-schema:Whale"s));
+ datastore.commitChanges();
+ expected = {
+ {"/example-schema:beast", identityRef_{"example-schema", "Whale"}},
+ };
+ REQUIRE(datastore.getItems("/example-schema:beast") == expected);
+ }
+
SECTION("operational data")
{
MockDataSupplier mockOpsData;
diff --git a/tests/example-schema.yang b/tests/example-schema.yang
index ac7724a..a24b891 100644
--- a/tests/example-schema.yang
+++ b/tests/example-schema.yang
@@ -214,4 +214,29 @@
type int32;
config false;
}
+
+ identity Animal {
+ }
+
+ identity Mammal {
+ base "Animal";
+ }
+
+ identity Dog {
+ base "Mammal";
+ }
+
+ identity Whale {
+ base "Mammal";
+ }
+
+ identity Velociraptor {
+ base "Animal";
+ }
+
+ leaf beast {
+ type identityref {
+ base "Animal";
+ }
+ }
}