You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2017/12/18 16:56:17 UTC

[GitHub] houshengbo commented on a change in pull request #3103: Rewrite wsk basic tests

houshengbo commented on a change in pull request #3103: Rewrite wsk basic tests
URL: https://github.com/apache/incubator-openwhisk/pull/3103#discussion_r157540709
 
 

 ##########
 File path: tests/src/test/scala/common/rest/WskRest.scala
 ##########
 @@ -1325,19 +1358,33 @@ class RunWskRestCmd() extends FlatSpec with RunWskCmd with Matchers with ScalaFu
   }
 
   def fullEntityName(name: String)(implicit wp: WskProps) = {
-    val sep = "/"
-    if (name.startsWith(sep)) name
-    else s"/${wp.namespace}/$name"
+    name.split("/") match {
+      // Example: /namespace/package_name/entity_name
+      case Array(empty, namespace, packageName, entityName) if empty.isEmpty => s"/$namespace/$packageName/$entityName"
+      // Example: /namespace/entity_name
+      case Array(empty, namespace, entityName) if empty.isEmpty => s"/$namespace/$entityName"
+      // Example: namespace/package_name/entity_name
+      case Array(namespace, packageName, entityName) => s"/$namespace/$packageName/$entityName"
+      // Example: /namespace
+      case Array(empty, namespace) if empty.isEmpty => namespace
+      // Example: package_name/entity_name
+      case Array(packageName, entityName) if !packageName.isEmpty => s"/${wp.namespace}/$packageName/$entityName"
+      // Example: entity_name
+      case Array(entityName) => s"/${wp.namespace}/$name"
+      case _                 => s"/${wp.namespace}/$name"
+    }
   }
 
-  def convertIntoComponents(comps: String)(implicit wp: WskProps): JsArray = {
+  def convertIntoComponents(comps: String)(implicit wp: WskProps): Vector[JsString] = {
     var paramsList = Vector[JsString]()
-    comps.split(",") foreach {
-      case (value) =>
-        val fullName = fullEntityName(value)
-        paramsList :+= JsString(fullName)
+    if (!comps.isEmpty()) {
+      comps.split(",") foreach {
+        case (value) =>
+          val fullName = fullEntityName(value)
+          paramsList :+= JsString(fullName)
+      }
     }
 
 Review comment:
   Done.

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


With regards,
Apache Git Services