Merge branch 'master' into 13804-no-shutdown-wanted-nodes
[arvados.git] / sdk / R / tests / testthat / test-util.R
index 62065f8e88f106b3bf988c418f242d57176cf5fa..9f5e07c1767af6c089274a308dc3dc270fb25c2f 100644 (file)
@@ -1,5 +1,33 @@
+# Copyright (C) The Arvados Authors. All rights reserved.
+#
+# SPDX-License-Identifier: Apache-2.0
+
 context("Utility function")
 
+test_that("listAll always returns all resource items from server", {
+
+    serverResponseLimit <- 3
+    itemsAvailable <- 8
+    items <- list("collection1", "collection2", "collection3", "collection4",
+                  "collection5", "collection6", "collection7", "collection8")
+
+    testFunction <- function(offset, ...)
+    {
+        response <- list()
+        response$items_available <- itemsAvailable
+
+        maxIndex <- offset + serverResponseLimit
+        lastElementIndex <- if(maxIndex < itemsAvailable) maxIndex else itemsAvailable
+
+        response$items <- items[(offset + 1):lastElementIndex]
+        response
+    }
+
+    result <- listAll(testFunction)
+
+    expect_that(length(result), equals(8))
+}) 
+
 test_that("trimFromStart trims string correctly if string starts with trimCharacters", {
 
     sample <- "./something/random"