X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8ca0b1449607ded51e908481cc4660c20f43a777..32b8eda74f24d1df963a18da5f8023b15d209ca9:/sdk/R/tests/testthat/test-util.R diff --git a/sdk/R/tests/testthat/test-util.R b/sdk/R/tests/testthat/test-util.R index 62065f8e88..ea091517c6 100644 --- a/sdk/R/tests/testthat/test-util.R +++ b/sdk/R/tests/testthat/test-util.R @@ -1,5 +1,29 @@ 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"