openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rab...@apache.org
Subject [incubator-openwhisk] branch master updated: Add an action runner test to ensure /init is only called once. (#3841)
Date Thu, 05 Jul 2018 15:55:21 GMT
This is an automated email from the ASF dual-hosted git repository.

rabbah pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git


The following commit(s) were added to refs/heads/master by this push:
     new c31dfea  Add an action runner test to ensure /init is only called once. (#3841)
c31dfea is described below

commit c31dfea58f1a633e4390f169d2c8055012d39704
Author: Rob Allen <rob@akrabat.com>
AuthorDate: Thu Jul 5 16:55:18 2018 +0100

    Add an action runner test to ensure /init is only called once. (#3841)
---
 .../actionContainers/BasicActionRunnerTests.scala  | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/tests/src/test/scala/actionContainers/BasicActionRunnerTests.scala b/tests/src/test/scala/actionContainers/BasicActionRunnerTests.scala
index 7072c86..3d85fa0 100644
--- a/tests/src/test/scala/actionContainers/BasicActionRunnerTests.scala
+++ b/tests/src/test/scala/actionContainers/BasicActionRunnerTests.scala
@@ -166,4 +166,27 @@ trait BasicActionRunnerTests extends ActionProxyContainerTestUtils {
     }
   }
 
+  /**
+   * Runs tests for actions which do not allow more than one initialisation and confirms
expected error messages.
+   * @param code the code to execute, should be valid
+   */
+  def testInitCannotBeCalledMoreThanOnce(code: String) = {
+    it should "fail to initialize a second time" in {
+      val (out, err) = withActionContainer() { c =>
+        val (initCode1, _) = c.init(initPayload(code))
+        initCode1 should be(200)
+
+        val (initCode2, error2) = c.init(initPayload(code))
+        initCode2 should be(403)
+        error2 shouldBe a[Some[_]]
+        error2.get shouldBe a[JsObject]
+        error2.get.fields("error").toString should include("Cannot initialize the action
more than once.")
+      }
+
+      checkStreams(out, err, {
+        case (o, e) =>
+          (o + e) should include("Cannot initialize the action more than once")
+      })
+    }
+  }
 }


Mime
View raw message