markusthoemmes commented on a change in pull request #4387: Make tests working 
in case the "provide-api-key" feature is disabled
URL: 
https://github.com/apache/incubator-openwhisk/pull/4387#discussion_r269885390
 
 

 ##########
 File path: 
tests/src/test/scala/org/apache/openwhisk/core/cli/test/WskRestBasicUsageTests.scala
 ##########
 @@ -430,13 +433,49 @@ class WskRestBasicUsageTests extends TestHelpers with 
WskTestHelpers with WskAct
         action.create(name, Some(TestUtils.getTestActionFilename("echo.js")), 
web = Some(flag.toLowerCase))
       }
 
-      val action = wsk.action.get(name)
-      action.getFieldJsValue("annotations").convertTo[Set[JsObject]] shouldBe 
Set(
+      val expectedSet = Set(
         JsObject("key" -> JsString("exec"), "value" -> JsString("nodejs:6")),
-        JsObject("key" -> WhiskAction.provideApiKeyAnnotationName.toJson, 
"value" -> JsBoolean(false)),
         JsObject("key" -> JsString("web-export"), "value" -> 
JsBoolean(webEnabled || rawEnabled)),
         JsObject("key" -> JsString("raw-http"), "value" -> 
JsBoolean(rawEnabled)),
         JsObject("key" -> JsString("final"), "value" -> JsBoolean(webEnabled 
|| rawEnabled)))
+
+      val action = wsk.action.get(name)
+      action.getFieldJsValue("annotations").convertTo[Set[JsObject]] shouldBe 
(if (requireAPIKeyAnnotation) {
 
 Review comment:
   I'd propose something like:
   
   ```scala
   val baseAnnotations = Parameters("exec", "nodejs:6") ++ 
Parameters("web-export", JsBoolean(webEnabled || rawEnabled)) ++ 
Parameters("raw-http", JsBoolean(rawEnabled)) ...
   val testAnnotations = if(requireAPIKeyAnnotation) baseAnnotations ++ 
Parameters(WhiskAction.provideApiKeyAnnotationName, JsFalse) else 
baseAnnotations
   
   action.getFieldJsValue("annotations") shouldBe testAnnotations.toJsArray
   ```
   
   (no compiler locally so can't try it out, but something along these lines 
should work)

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


With regards,
Apache Git Services

Reply via email to