CLI & entity/invoker support for --main for NodeJS/Python/Swift.
diff --git a/tests/src/actionContainers/NodeJs6ActionContainerTests.scala b/tests/src/actionContainers/NodeJs6ActionContainerTests.scala
index 4910978..7b7992f 100644
--- a/tests/src/actionContainers/NodeJs6ActionContainerTests.scala
+++ b/tests/src/actionContainers/NodeJs6ActionContainerTests.scala
@@ -29,7 +29,7 @@
override lazy val nodejsContainerImageName = "nodejs6action"
- override def exec(code: String) = NodeJS6Exec(code)
+ override def exec(code: String) = NodeJS6Exec(code, None)
behavior of nodejsContainerImageName
diff --git a/tests/src/actionContainers/NodeJsActionContainerTests.scala b/tests/src/actionContainers/NodeJsActionContainerTests.scala
index 00cbf25..5444b9f 100644
--- a/tests/src/actionContainers/NodeJsActionContainerTests.scala
+++ b/tests/src/actionContainers/NodeJsActionContainerTests.scala
@@ -39,7 +39,7 @@
def withNodeJsContainer(code: ActionContainer => Unit) = withActionContainer()(code)
- def exec(code: String): NodeJSAbstractExec = NodeJSExec(code)
+ def exec(code: String): NodeJSAbstractExec = NodeJSExec(code, None)
override def initPayload(code: String, main: String = "main") = {
val e = exec(code)
diff --git a/tests/src/system/basic/CLIPythonTests.scala b/tests/src/system/basic/CLIPythonTests.scala
index 891745b..b0417d6 100644
--- a/tests/src/system/basic/CLIPythonTests.scala
+++ b/tests/src/system/basic/CLIPythonTests.scala
@@ -54,6 +54,18 @@
}
}
+ it should "invoke an action with a non-default entry point" in withAssetCleaner(wskprops) {
+ (wp, assetHelper) =>
+ val name = "nonDefaultEntryPoint"
+ assetHelper.withCleaner(wsk.action, name) {
+ (action, _) => action.create(name, Some(TestUtils.getTestActionFilename("niam.py")), main = Some("niam"))
+ }
+
+ withActivation(wsk.activation, wsk.action.invoke(name, Map())) {
+ _.response.result.get.fields.get("greetings") should be(Some(JsString("Hello from a non-standard entrypoint.")))
+ }
+ }
+
it should "invoke an action and confirm expected environment is defined" in withAssetCleaner(wskprops) {
(wp, assetHelper) =>
val name = "stdenv"
diff --git a/tests/src/system/basic/WskBasicNodeTests.scala b/tests/src/system/basic/WskBasicNodeTests.scala
index 4f50071..cb90ca9 100644
--- a/tests/src/system/basic/WskBasicNodeTests.scala
+++ b/tests/src/system/basic/WskBasicNodeTests.scala
@@ -30,6 +30,7 @@
import spray.json.DefaultJsonProtocol.StringJsonFormat
import spray.json.pimpAny
import spray.json.pimpString
+import spray.json.JsString
import common.TestUtils.RunResult
import spray.json.JsObject
@@ -63,6 +64,24 @@
}
}
+ it should "Ensure that NodeJS actions can have a non-default entrypoint" in withAssetCleaner(wskprops) {
+ (wp, assetHelper) =>
+ val name = "niamNpmAction"
+ val file = Some(TestUtils.getTestActionFilename("niam.js"))
+
+ assetHelper.withCleaner(wsk.action, name) {
+ (action, _) =>
+ action.create(name, file, main = Some("niam"))
+ }
+
+ withActivation(wsk.activation, wsk.action.invoke(name)) {
+ activation =>
+ val response = activation.response
+ response.result.get.fields.get("error") shouldBe empty
+ response.result.get.fields.get("greetings") should be(Some(JsString("Hello from a non-standard entrypoint.")))
+ }
+ }
+
it should "Ensure that zipped actions are encoded and uploaded as NodeJS actions" in withAssetCleaner(wskprops) {
(wp, assetHelper) =>
val name = "zippedNpmAction"
diff --git a/tests/src/system/basic/WskBasicSwiftTests.scala b/tests/src/system/basic/WskBasicSwiftTests.scala
index 82c2af1..4455861 100644
--- a/tests/src/system/basic/WskBasicSwiftTests.scala
+++ b/tests/src/system/basic/WskBasicSwiftTests.scala
@@ -28,6 +28,7 @@
import spray.json.DefaultJsonProtocol.StringJsonFormat
import spray.json.pimpAny
import spray.json.pimpString
+import spray.json.JsString
import common.TestUtils.RunResult
import spray.json.JsObject
@@ -61,6 +62,24 @@
}
}
+ it should "Ensure that Swift actions can have a non-default entrypoint" in withAssetCleaner(wskprops) {
+ (wp, assetHelper) =>
+ val name = "niamSwiftAction"
+ val file = Some(TestUtils.getTestActionFilename("niam.swift"))
+
+ assetHelper.withCleaner(wsk.action, name) {
+ (action, _) =>
+ action.create(name, file, main = Some("niam"))
+ }
+
+ withActivation(wsk.activation, wsk.action.invoke(name)) {
+ activation =>
+ val response = activation.response
+ response.result.get.fields.get("error") shouldBe empty
+ response.result.get.fields.get("greetings") should be(Some(JsString("Hello from a non-standard entrypoint.")))
+ }
+ }
+
def convertRunResultToJsObject(result: RunResult): JsObject = {
val stdout = result.stdout
val firstNewline = stdout.indexOf("\n")