Fix crash when execing invalid RPC
When executing an invalid RPC, the temporary datastore wasn't being
properly canceled.
Issue: https://tree.taiga.io/project/jktjkt-netconf-cli/issue/209
Change-Id: I56e301c509781275bd960f4cd846d649507a875d
diff --git a/tests/datastore_access.cpp b/tests/datastore_access.cpp
index ececd0c..9eeed2a 100644
--- a/tests/datastore_access.cpp
+++ b/tests/datastore_access.cpp
@@ -17,6 +17,7 @@
using OnInvalidSchemaPathDelete = DatastoreException;
using OnInvalidSchemaPathMove = sysrepo::sysrepo_exception;
using OnInvalidRpcPath = sysrepo::sysrepo_exception;
+using OnInvalidRpcInput = sysrepo::sysrepo_exception;
using OnKeyNotFound = void;
using OnExec = void;
#elif defined(netconf_BACKEND)
@@ -24,6 +25,7 @@
using OnInvalidSchemaPathDelete = std::runtime_error;
using OnInvalidSchemaPathMove = std::runtime_error;
using OnInvalidRpcPath = std::runtime_error;
+using OnInvalidRpcInput = std::runtime_error;
using OnKeyNotFound = std::runtime_error;
using OnExec = void;
#include "netconf_access.hpp"
@@ -35,6 +37,7 @@
using OnInvalidSchemaPathDelete = DatastoreException;
using OnInvalidSchemaPathMove = DatastoreException;
using OnInvalidRpcPath = DatastoreException;
+using OnInvalidRpcInput = std::logic_error;
using OnKeyNotFound = DatastoreException;
using OnExec = std::logic_error;
#else
@@ -1024,6 +1027,13 @@
{
catching<OnInvalidRpcPath>([&] { datastore->execute("/example-schema:non-existing", DatastoreAccess::Tree{}); });
}
+
+ SECTION("invalid RPC exec resets temporary datastore")
+ {
+ proxyDatastore.initiate("/example-schema:setIp");
+ catching<OnInvalidRpcInput>([&] { auto output = proxyDatastore.execute(); });
+ REQUIRE(proxyDatastore.inputDatastorePath() == std::nullopt);
+ }
}
SECTION("action")