Skip to content

Commit

Permalink
Fix DocumentHandlerTests
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangpengcheng committed Oct 13, 2020
1 parent 19f30b4 commit 34938f8
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import spray.json.DefaultJsonProtocol._
import spray.json._
import org.apache.openwhisk.common.TransactionId
import org.apache.openwhisk.core.database.SubjectHandler.SubjectView
import org.apache.openwhisk.core.database.WhisksHandler.ROOT_NS
import org.apache.openwhisk.core.database.WhisksHandler.{FULL_NAME, ROOT_NS}
import org.apache.openwhisk.core.database._
import org.apache.openwhisk.core.entity._

Expand All @@ -48,14 +48,18 @@ class DocumentHandlerTests extends FlatSpec with Matchers with ScalaFutures with

it should "return JsObject when namespace is simple name" in {
WhisksHandler.computedFields(JsObject(("namespace", JsString("foo")))) shouldBe JsObject((ROOT_NS, JsString("foo")))
WhisksHandler.computedFields(newRule("foo").toDocumentRecord) shouldBe JsObject((ROOT_NS, JsString("foo")))
WhisksHandler.computedFields(newRule("foo").toDocumentRecord) shouldBe JsObject(
(ROOT_NS, JsString("foo")),
(FULL_NAME, JsString("foo/foo")))
}

it should "return JsObject when namespace is path" in {
WhisksHandler.computedFields(JsObject(("namespace", JsString("foo/bar")))) shouldBe
JsObject((ROOT_NS, JsString("foo")))

WhisksHandler.computedFields(newRule("foo/bar").toDocumentRecord) shouldBe JsObject((ROOT_NS, JsString("foo")))
WhisksHandler.computedFields(newRule("foo/bar").toDocumentRecord) shouldBe JsObject(
(ROOT_NS, JsString("foo")),
(FULL_NAME, JsString("foo/bar/foo")))
}

private def newRule(ns: String): WhiskRule = {
Expand Down

0 comments on commit 34938f8

Please sign in to comment.