markusthoemmes commented on a change in pull request #3950: Extend system 
testsuite
URL: 
https://github.com/apache/incubator-openwhisk/pull/3950#discussion_r208497477
 
 

 ##########
 File path: tests/src/test/scala/system/basic/WskActionTests.scala
 ##########
 @@ -71,6 +71,49 @@ class WskActionTests extends TestHelpers with 
WskTestHelpers with JsHelpers with
     }
   }
 
+  it should "invoke an action that throws an uncaught exception and returns 
correct status code" in withAssetCleaner(
+    wskprops) { (wp, assetHelper) =>
+    val name = "throwExceptionAction"
+    assetHelper.withCleaner(wsk.action, name) { (action, _) =>
+      action.create(name, 
Some(TestUtils.getTestActionFilename("runexception.js")))
+    }
+
+    withActivation(wsk.activation, wsk.action.invoke(name)) { activation =>
+      val response = activation.response
+      activation.response.status shouldBe "action developer error"
+      activation.response.result shouldBe Some(
+        JsObject("error" -> "An error has occurred: Extraordinary 
exception".toJson))
+    }
+  }
+
+  it should "invoke an action with option --blocking only and verify output" 
in withAssetCleaner(wskprops) {
+    (wp, assetHelper) =>
+      val name = "invokeResult"
+      assetHelper.withCleaner(wsk.action, name) { (action, _) =>
+        action.create(name, Some(TestUtils.getTestActionFilename("echo.js")))
+      }
+      val args = Map("hello" -> "Robert".toJson)
+      val run = wsk.action.invoke(name, args, blocking = true)
+
+      run.stdout.parseJson.asJsObject.getFieldPath("response", 
"result").get.asJsObject shouldBe JsObject(args)
+
+      run.stdout.parseJson.asJsObject
+        .getFields(
+          "activationId",
+          "annotations",
+          "duration",
+          "end",
+          "logs",
+          "name",
+          "namespace",
+          "publish",
+          "response",
+          "start",
+          "subject",
+          "version")
+        .size shouldBe 12
 
 Review comment:
   When checking for size, ScalaTest has a matcher for that: `should have size 
12` will print the whole sequence on failure and thus give you a more 
explanatory error output than `11 was not 12`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to