adam-markovics commented on a change in pull request #1232:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1232#discussion_r778829451



##########
File path: 
extensions/script/tests/TestExecuteScriptProcessorWithPythonScript.cpp
##########
@@ -27,7 +27,47 @@
 #include "processors/GetFile.h"
 #include "processors/PutFile.h"
 
-TEST_CASE("Python: Test Read File", "[executescriptPythonRead]") { // NOLINT
+TEST_CASE("Script engine is not set", "[executescriptMisconfiguration]") {
+  TestController testController;
+  auto plan = testController.createPlan();
+
+  auto executeScript = plan->addProcessor("ExecuteScript", "executeScript");
+
+  plan->setProperty(executeScript, 
minifi::processors::ExecuteScript::ScriptEngine.getName(), "");
+  plan->setProperty(executeScript, 
minifi::processors::ExecuteScript::ScriptFile.getName(), "/path/to/script.py");
+
+  REQUIRE_THROWS_AS(testController.runSession(plan, true), minifi::Exception);
+}
+
+TEST_CASE("Neither script body nor script file is set", 
"[executescriptMisconfiguration]") {
+  TestController testController;
+  auto plan = testController.createPlan();
+
+  auto executeScript = plan->addProcessor("ExecuteScript", "executeScript");
+
+  plan->setProperty(executeScript, 
minifi::processors::ExecuteScript::ScriptEngine.getName(), "python");
+
+  REQUIRE_THROWS_AS(testController.runSession(plan, true), minifi::Exception);
+}
+
+TEST_CASE("Test both script body and script file set", 
"[executescriptMisconfiguration]") {
+  TestController testController;
+  auto plan = testController.createPlan();
+
+  auto executeScript = plan->addProcessor("ExecuteScript", "executeScript");
+
+  plan->setProperty(executeScript, 
minifi::processors::ExecuteScript::ScriptEngine.getName(), "python");
+  plan->setProperty(executeScript, 
minifi::processors::ExecuteScript::ScriptFile.getName(), "/path/to/script.py");
+  plan->setProperty(executeScript, 
minifi::processors::ExecuteScript::ScriptBody.getName(), R"(
+    function onTrigger(context, session)

Review comment:
       I think Python code would suit better here. Just to make sure the 
exception is not coming because of the wrong code syntax.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to