openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From csantan...@apache.org
Subject [incubator-openwhisk-cli] 05/16: Replace the test cases of action and package with REST implementation (#2621)
Date Wed, 15 Nov 2017 17:34:16 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 2120761c296d6c601e5c036a3fd1047afe1b4d9f
Author: Vincent <shou@us.ibm.com>
AuthorDate: Tue Oct 24 14:38:59 2017 -0400

    Replace the test cases of action and package with REST implementation (#2621)
    
    Partially-closes: #2430
---
 .../test/scala/system/basic/WskActionTests.scala   | 22 ++++++-----------
 .../test/scala/system/basic/WskBasicTests.scala    |  5 ++--
 .../scala/system/basic/WskCliActionTests.scala     | 28 ++++++++++++++++++++++
 .../scala/system/basic/WskCliPackageTests.scala    | 28 ++++++++++++++++++++++
 .../test/scala/system/basic/WskPackageTests.scala  |  9 ++++---
 5 files changed, 70 insertions(+), 22 deletions(-)

diff --git a/tests/src/test/scala/system/basic/WskActionTests.scala b/tests/src/test/scala/system/basic/WskActionTests.scala
index 519f50b..28d074b 100644
--- a/tests/src/test/scala/system/basic/WskActionTests.scala
+++ b/tests/src/test/scala/system/basic/WskActionTests.scala
@@ -25,6 +25,7 @@ import common.JsHelpers
 import common.TestHelpers
 import common.TestCLIUtils
 import common.TestUtils
+import common.BaseWsk
 import common.Wsk
 import common.WskProps
 import common.WskTestHelpers
@@ -34,10 +35,10 @@ import spray.json.JsObject
 import spray.json.pimpAny
 
 @RunWith(classOf[JUnitRunner])
-class WskActionTests extends TestHelpers with WskTestHelpers with JsHelpers {
+abstract class WskActionTests extends TestHelpers with WskTestHelpers with JsHelpers {
 
   implicit val wskprops = WskProps()
-  val wsk = new Wsk
+  val wsk: BaseWsk
 
   val testString = "this is a test"
   val testResult = JsObject("count" -> testString.split(" ").length.toJson)
@@ -141,8 +142,8 @@ class WskActionTests extends TestHelpers with WskTestHelpers with JsHelpers
{
         action.create(copiedActionName, Some(origActionName), Some("copy"))
       }
 
-      val copiedAction = getJSONFromCLIResponse(wsk.action.get(copiedActionName).stdout)
-      val origAction = getJSONFromCLIResponse(wsk.action.get(copiedActionName).stdout)
+      val copiedAction = getJSONFromResponse(wsk.action.get(copiedActionName).stdout, wsk.isInstanceOf[Wsk])
+      val origAction = getJSONFromResponse(wsk.action.get(copiedActionName).stdout, wsk.isInstanceOf[Wsk])
 
       copiedAction.fields("annotations") shouldBe origAction.fields("annotations")
       copiedAction.fields("parameters") shouldBe origAction.fields("parameters")
@@ -177,10 +178,11 @@ class WskActionTests extends TestHelpers with WskTestHelpers with JsHelpers
{
       }
 
       assetHelper.withCleaner(wsk.action, copiedName) { (action, _) =>
+        println("created copied ")
         action.create(copiedName, Some(origName), Some("copy"), parameters = copiedParams,
annotations = copiedAnnots)
       }
 
-      val copiedAction = getJSONFromCLIResponse(wsk.action.get(copiedName).stdout)
+      val copiedAction = getJSONFromResponse(wsk.action.get(copiedName).stdout, wsk.isInstanceOf[Wsk])
 
       // CLI does not guarantee order of annotations and parameters so do a diff to compare
the values
       copiedAction.fields("parameters").convertTo[Seq[JsObject]] diff resParams shouldBe
List()
@@ -268,16 +270,6 @@ class WskActionTests extends TestHelpers with WskTestHelpers with JsHelpers
{
     }
   }
 
-  it should "reject an invoke with the wrong parameters set" in withAssetCleaner(wskprops)
{ (wp, assetHelper) =>
-    val fullQualifiedName = s"/$guestNamespace/samples/helloWorld"
-    val payload = "bob"
-    val rr = wsk.cli(
-      Seq("action", "invoke", fullQualifiedName, payload) ++ wskprops.overrides,
-      expectedExitCode = TestUtils.ERROR_EXIT)
-    rr.stderr should include("Run 'wsk --help' for usage.")
-    rr.stderr should include(s"error: Invalid argument(s): $payload")
-  }
-
   it should "not be able to use 'ping' in an action" in withAssetCleaner(wskprops) { (wp,
assetHelper) =>
     val name = "ping"
     assetHelper.withCleaner(wsk.action, name) { (action, _) =>
diff --git a/tests/src/test/scala/system/basic/WskBasicTests.scala b/tests/src/test/scala/system/basic/WskBasicTests.scala
index f206e64..9a02bdb 100644
--- a/tests/src/test/scala/system/basic/WskBasicTests.scala
+++ b/tests/src/test/scala/system/basic/WskBasicTests.scala
@@ -355,8 +355,9 @@ class WskBasicTests extends TestHelpers with WskTestHelpers {
     }
 
     Seq(strErrInput, numErrInput, boolErrInput) foreach { input =>
-      getJSONFromCLIResponse(
-        wsk.action.invoke(name, parameters = input, blocking = true, expectedExitCode = 246).stderr)
+      getJSONFromResponse(
+        wsk.action.invoke(name, parameters = input, blocking = true, expectedExitCode = 246).stderr,
+        wsk.isInstanceOf[Wsk])
         .fields("response")
         .asJsObject
         .fields("result")
diff --git a/tests/src/test/scala/system/basic/WskCliActionTests.scala b/tests/src/test/scala/system/basic/WskCliActionTests.scala
new file mode 100644
index 0000000..b7649f6
--- /dev/null
+++ b/tests/src/test/scala/system/basic/WskCliActionTests.scala
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package system.basic
+
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+import common.Wsk
+
+@RunWith(classOf[JUnitRunner])
+class WskCliActionTests extends WskActionTests {
+  override val wsk = new Wsk
+}
diff --git a/tests/src/test/scala/system/basic/WskCliPackageTests.scala b/tests/src/test/scala/system/basic/WskCliPackageTests.scala
new file mode 100644
index 0000000..e3a3f84
--- /dev/null
+++ b/tests/src/test/scala/system/basic/WskCliPackageTests.scala
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package system.basic
+
+import org.junit.runner.RunWith
+import org.scalatest.junit.JUnitRunner
+
+import common.Wsk
+
+@RunWith(classOf[JUnitRunner])
+class WskCliPackageTests extends WskPackageTests {
+  override val wsk: Wsk = new Wsk
+}
diff --git a/tests/src/test/scala/system/basic/WskPackageTests.scala b/tests/src/test/scala/system/basic/WskPackageTests.scala
index 40c93e6..80686c5 100644
--- a/tests/src/test/scala/system/basic/WskPackageTests.scala
+++ b/tests/src/test/scala/system/basic/WskPackageTests.scala
@@ -24,7 +24,7 @@ import scala.concurrent.duration.DurationInt
 import org.junit.runner.RunWith
 import org.scalatest.junit.JUnitRunner
 import common.TestCLIUtils
-import common.Wsk
+import common.BaseWsk
 import common.WskProps
 import spray.json._
 import spray.json.DefaultJsonProtocol.StringJsonFormat
@@ -34,10 +34,10 @@ import common.TestHelpers
 import common.WskProps
 
 @RunWith(classOf[JUnitRunner])
-class WskPackageTests extends TestHelpers with WskTestHelpers {
+abstract class WskPackageTests extends TestHelpers with WskTestHelpers {
 
   implicit val wskprops = WskProps()
-  val wsk = new Wsk
+  val wsk: BaseWsk
   val LOG_DELAY = 80 seconds
 
   behavior of "Wsk Package"
@@ -128,9 +128,8 @@ class WskPackageTests extends TestHelpers with WskTestHelpers {
     val flatDescription = itemDescription.replace("\n", "").replace("\r", "")
     merged.foreach {
       case (key: String, value: JsValue) =>
-        val toFind = s""""key": "${key}",.*"value": ${value.toString}"""
+        val toFind = s""""key":.*"${key}",.*"value":.*${value.toString}"""
         flatDescription should include regex toFind
     }
   }
-
 }

-- 
To stop receiving notification emails like this one, please contact
"commits@openwhisk.apache.org" <commits@openwhisk.apache.org>.

Mime
View raw message