openwhisk-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From csantan...@apache.org
Subject [incubator-openwhisk-cli] 06/16: Update the test cases about rules with REST implementation (#2895)
Date Wed, 15 Nov 2017 17:34:17 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 c073786f7c514168a72287048bb0214ce21bd222
Author: Vincent <shou@us.ibm.com>
AuthorDate: Tue Oct 31 13:09:44 2017 -0400

    Update the test cases about rules with REST implementation (#2895)
---
 .../test/scala/system/basic/WskCliRuleTests.scala  | 28 ++++++++++++++++++++++
 .../src/test/scala/system/basic/WskRuleTests.scala | 20 ++++++++++------
 2 files changed, 41 insertions(+), 7 deletions(-)

diff --git a/tests/src/test/scala/system/basic/WskCliRuleTests.scala b/tests/src/test/scala/system/basic/WskCliRuleTests.scala
new file mode 100644
index 0000000..6c63077
--- /dev/null
+++ b/tests/src/test/scala/system/basic/WskCliRuleTests.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 WskCliRuleTests extends WskRuleTests {
+  override val wsk: Wsk = new Wsk
+}
diff --git a/tests/src/test/scala/system/basic/WskRuleTests.scala b/tests/src/test/scala/system/basic/WskRuleTests.scala
index adc95a7..a7929ba 100644
--- a/tests/src/test/scala/system/basic/WskRuleTests.scala
+++ b/tests/src/test/scala/system/basic/WskRuleTests.scala
@@ -21,7 +21,8 @@ import org.junit.runner.RunWith
 import org.scalatest.junit.JUnitRunner
 import common.TestHelpers
 import common.TestCLIUtils
-import common.Wsk
+import common.TestUtils.RunResult
+import common.BaseWsk
 import common.WskProps
 import common.WskTestHelpers
 import spray.json._
@@ -29,10 +30,10 @@ import spray.json.DefaultJsonProtocol._
 import java.time.Instant
 
 @RunWith(classOf[JUnitRunner])
-class WskRuleTests extends TestHelpers with WskTestHelpers {
+abstract class WskRuleTests extends TestHelpers with WskTestHelpers {
 
   implicit val wskprops = WskProps()
-  val wsk = new Wsk
+  val wsk: BaseWsk
   val defaultAction = TestCLIUtils.getTestActionFilename("wc.js")
   val secondAction = TestCLIUtils.getTestActionFilename("hello.js")
   val testString = "this is a test"
@@ -413,10 +414,15 @@ class WskRuleTests extends TestHelpers with WskTestHelpers {
         assetHelper)
 
       wsk.rule.disable(ruleName)
-      val listOutput = wsk.rule.list().stdout.lines
-      listOutput.find(_.contains(ruleName2)).get should (include(ruleName2) and include("active"))
-      listOutput.find(_.contains(ruleName)).get should (include(ruleName) and include("inactive"))
-      wsk.rule.list().stdout should not include ("Unknown")
+      val ruleListResult = wsk.rule.list()
+      verifyRuleList(ruleListResult, ruleName2, ruleName)
   }
 
+  def verifyRuleList(ruleListResult: RunResult, ruleNameEnable: String, ruleName: String)
= {
+    val ruleList = ruleListResult.stdout
+    val listOutput = ruleList.lines
+    listOutput.find(_.contains(ruleNameEnable)).get should (include(ruleNameEnable) and include("active"))
+    listOutput.find(_.contains(ruleName)).get should (include(ruleName) and include("inactive"))
+    ruleList should not include ("Unknown")
+  }
 }

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

Mime
View raw message