You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by cs...@apache.org on 2017/08/10 12:08:35 UTC
[incubator-openwhisk-cli] 10/11: Ensure Action Update Creates a Web
Action (#2435)
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 19a3a55145cedefcc892a942bbd806556c9ff6e8
Author: James Dubee <jw...@us.ibm.com>
AuthorDate: Wed Aug 9 13:18:50 2017 -0400
Ensure Action Update Creates a Web Action (#2435)
* Ensure Action Update Creates a Web ActionEnsure Action Update Creates a Web ActionEnsure Action Update Creates a Web ActionEnsure Action Update Creates a Web ActionEnsure Action Update Creates a Web ActionEnsure Action Update Creates a Web ActionEnsure Action Update Creates a Web ActionEnsure Action Update Creates a Web ActionEnsure Action Update Creates a Web Action
* Ensure Existing Annotations are Overwritten
- Overwrite annotations that have matching keys with most recent values
---
.../scala/whisk/core/cli/test/ApiGwTests.scala | 12 +---
.../whisk/core/cli/test/WskBasicUsageTests.scala | 77 +++++++++++++++++++---
.../whisk/core/cli/test/WskWebActionsTests.scala | 2 +-
3 files changed, 71 insertions(+), 20 deletions(-)
diff --git a/tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala b/tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala
index 0944044..b478781 100644
--- a/tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/ApiGwTests.scala
@@ -412,11 +412,7 @@ class ApiGwTests
val testurlop = "get"
val testapiname = testName+" API Name"
val actionName = testName+"_action"
-<<<<<<< HEAD
- val swaggerPath = TestCLIUtils.getTestApiGwFilename("testswaggerdoc1V2")
-=======
- val swaggerPath = TestUtils.getTestApiGwFilename("testswaggerdoc1")
->>>>>>> a509e00... Remove "experimental" gateway api (#2547)
+ val swaggerPath = TestCLIUtils.getTestApiGwFilename("testswaggerdoc1")
try {
var rr = apiCreate(swagger = Some(swaggerPath))
rr.stdout should include("ok: created API")
@@ -598,11 +594,7 @@ class ApiGwTests
val testurlop = "get"
val testapiname = testName + " API Name"
val actionName = "test1a"
-<<<<<<< HEAD
- val swaggerPath = TestCLIUtils.getTestApiGwFilename(s"testswaggerdoc2V2")
-=======
- val swaggerPath = TestUtils.getTestApiGwFilename(s"testswaggerdoc2")
->>>>>>> a509e00... Remove "experimental" gateway api (#2547)
+ val swaggerPath = TestCLIUtils.getTestApiGwFilename(s"testswaggerdoc2")
try {
var rr = apiCreate(swagger = Some(swaggerPath))
println("api create stdout: " + rr.stdout)
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala
index a9dd84b..814c461 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskBasicUsageTests.scala
@@ -511,20 +511,82 @@ class WskBasicUsageTests
}
}
- it should "ensure --web flag does not remove existing annotations" in withAssetCleaner(wskprops) {
+ it should "ensure action update with --web flag only copies existing annotations when new annotations are not provided" in withAssetCleaner(wskprops) {
(wp, assetHelper) =>
val name = "webaction"
val file = Some(TestCLIUtils.getTestActionFilename("echo.js"))
- val key = "someKey"
- val value = JsString("someValue")
- val annots = Map(key -> value)
+ val createKey = "createKey"
+ val createValue = JsString("createValue")
+ val updateKey = "updateKey"
+ val updateValue = JsString("updateValue")
+ val origKey = "origKey"
+ val origValue = JsString("origValue")
+ val overwrittenValue = JsString("overwrittenValue")
+ val createAnnots = Map(createKey -> createValue, origKey -> origValue)
+ val updateAnnots = Map(updateKey -> updateValue, origKey -> overwrittenValue)
assetHelper.withCleaner(wsk.action, name) {
- (action, _) => action.create(name, file, annotations = annots)
+ (action, _) => action.create(name, file, annotations = createAnnots)
}
wsk.action.create(name, file, web = Some("true"), update = true)
+ val existinAnnots = wsk.action.get(name, fieldFilter = Some("annotations")).stdout
+ assert(existinAnnots.startsWith(s"ok: got action $name, displaying field annotations\n"))
+ removeCLIHeader(existinAnnots).parseJson shouldBe JsArray(
+ JsObject(
+ "key" -> JsString("web-export"),
+ "value" -> JsBoolean(true)),
+ JsObject(
+ "key" -> JsString(origKey),
+ "value" -> origValue),
+ JsObject(
+ "key" -> JsString("raw-http"),
+ "value" -> JsBoolean(false)),
+ JsObject(
+ "key" -> JsString("final"),
+ "value" -> JsBoolean(true)),
+ JsObject(
+ "key" -> JsString(createKey),
+ "value" -> createValue),
+ JsObject(
+ "key" -> JsString("exec"),
+ "value" -> JsString("nodejs:6")))
+
+ wsk.action.create(name, file, web = Some("true"), update = true, annotations = updateAnnots)
+
+ val updatedAnnots = wsk.action.get(name, fieldFilter = Some("annotations")).stdout
+ assert(updatedAnnots.startsWith(s"ok: got action $name, displaying field annotations\n"))
+ removeCLIHeader(updatedAnnots).parseJson shouldBe JsArray(
+ JsObject(
+ "key" -> JsString("web-export"),
+ "value" -> JsBoolean(true)),
+ JsObject(
+ "key" -> JsString(origKey),
+ "value" -> overwrittenValue),
+ JsObject(
+ "key" -> JsString(updateKey),
+ "value" -> updateValue),
+ JsObject(
+ "key" -> JsString("raw-http"),
+ "value" -> JsBoolean(false)),
+ JsObject(
+ "key" -> JsString("final"),
+ "value" -> JsBoolean(true)),
+ JsObject(
+ "key" -> JsString("exec"),
+ "value" -> JsString("nodejs:6")))
+ }
+
+ it should "ensure action update creates an action with --web flag" in withAssetCleaner(wskprops) {
+ (wp, assetHelper) =>
+ val name = "webaction"
+ val file = Some(TestCLIUtils.getTestActionFilename("echo.js"))
+
+ assetHelper.withCleaner(wsk.action, name) {
+ (action, _) => action.create(name, file, web = Some("true"), update = true)
+ }
+
val stdout = wsk.action.get(name, fieldFilter = Some("annotations")).stdout
assert(stdout.startsWith(s"ok: got action $name, displaying field annotations\n"))
removeCLIHeader(stdout).parseJson shouldBe JsArray(
@@ -538,9 +600,6 @@ class WskBasicUsageTests
"key" -> JsString("final"),
"value" -> JsBoolean(true)),
JsObject(
- "key" -> JsString(key),
- "value" -> value),
- JsObject(
"key" -> JsString("exec"),
"value" -> JsString("nodejs:6")))
}
@@ -638,7 +697,7 @@ class WskBasicUsageTests
val params = Seq("-p", "bigValue", "a" * 1000)
assetHelper.withCleaner(wsk.action, name) {
- (action, _) => action.create(name, Some(TestUtils.getTestActionFilename("echo.js")))
+ (action, _) => action.create(name, Some(TestCLIUtils.getTestActionFilename("echo.js")))
}
val truncated = wsk.cli(Seq("action", "invoke", name, "-b", "-v", "--auth", wskprops.authKey) ++ params ++ wskprops.overrides).stdout
diff --git a/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala b/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
index 8fee896..070f356 100644
--- a/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
+++ b/tests/src/test/scala/whisk/core/cli/test/WskWebActionsTests.scala
@@ -301,7 +301,7 @@ trait WskWebActionsTests
it should "support multiple response header values" in withAssetCleaner(wskprops) {
(wp, assetHelper) =>
val name = "webaction"
- val file = Some(TestUtils.getTestActionFilename("multipleHeaders.js"))
+ val file = Some(TestCLIUtils.getTestActionFilename("multipleHeaders.js"))
val host = getServiceURL()
val url = host + s"$testRoutePath/$namespace/default/webaction.http"
--
To stop receiving notification emails like this one, please contact
"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>.