markusthoemmes commented on a change in pull request #3155: Support ?count on 
collections
URL: 
https://github.com/apache/incubator-openwhisk/pull/3155#discussion_r161247855
 
 

 ##########
 File path: 
tests/src/test/scala/whisk/core/controller/test/PackagesApiTests.scala
 ##########
 @@ -107,29 +123,31 @@ class PackagesApiTests extends ControllerTestCommon with 
WhiskPackagesApi {
     waitOnView(entityStore, WhiskPackage, namespaces(1), 1)
     waitOnView(entityStore, WhiskPackage, namespaces(2), 1)
     waitOnView(entityStore, WhiskPackage, namespaces(0), 1 + 4)
-    Get(s"$collectionPath") ~> Route.seal(routes(creds)) ~> check {
-      status should be(OK)
-      val response = responseAs[List[JsObject]]
-      val expected = providers.filter { _.namespace == namespace } ++ 
references
-      response.length should be >= (expected.length)
-      expected forall { p =>
-        (response contains p.summaryAsJson)
-      } should be(true)
+
+    {
+      val expected = providers.filter(_.namespace == namespace) ++ references
+      checkCount(expected = expected.length)
+      Get(s"$collectionPath") ~> Route.seal(routes(creds)) ~> check {
+        status should be(OK)
+        val response = responseAs[List[JsObject]]
+        response.length shouldBe expected.length
+        response should contain theSameElementsAs expected.map(_.summaryAsJson)
+      }
     }
 
-    val auser = WhiskAuthHelpers.newIdentity()
-    Get(s"/$namespace/${collection.path}") ~> Route.seal(routes(auser)) ~> 
check {
-      status should be(OK)
-      val response = responseAs[List[JsObject]]
-      val expected = providers.filter { p =>
-        p.namespace == namespace && p.publish
-      } ++ references.filter { p =>
-        p.publish && p.binding == None
+    {
+      val path = s"/$namespace/${collection.path}"
+      val auser = WhiskAuthHelpers.newIdentity()
+      val expected = providers.filter(p => p.namespace == namespace && 
p.publish) ++
+        references.filter(p => p.publish && p.binding == None)
+
+      checkCount(path, expected.length, auser)
+      Get(path) ~> Route.seal(routes(auser)) ~> check {
+        status should be(OK)
+        val response = responseAs[List[JsObject]]
+        response.length shouldBe expected.length
 
 Review comment:
   `response should have size expected.size` for a better error message? 
(applies to others)

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to