X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/539f2b151c57a76c9a8c0d49ef7ee5c0bac39de7..0b869f3fab26c33515cd9b2f44e0ed9c8c542698:/sdk/R/tests/testthat/test-Subcollection.R diff --git a/sdk/R/tests/testthat/test-Subcollection.R b/sdk/R/tests/testthat/test-Subcollection.R index 3572044ba8..b155ed4ccb 100644 --- a/sdk/R/tests/testthat/test-Subcollection.R +++ b/sdk/R/tests/testthat/test-Subcollection.R @@ -13,7 +13,7 @@ test_that("getRelativePath returns path relative to the tree root", { expect_that(fish$getRelativePath(), equals("animal/fish")) }) -test_that(paste("getFileListing by default returns path of all files", +test_that(paste("getFileListing by default returns sorted path of all files", "relative to the current subcollection"), { animal <- Subcollection$new("animal") @@ -26,7 +26,9 @@ test_that(paste("getFileListing by default returns path of all files", fish$add(blueFish) result <- animal$getFileListing() - expectedResult <- c("animal/fish/shark", "animal/fish/blueFish") + + #expect sorted array + expectedResult <- c("animal/fish/blueFish", "animal/fish/shark") resultsMatch <- length(expectedResult) == length(result) && all(expectedResult == result) @@ -34,7 +36,7 @@ test_that(paste("getFileListing by default returns path of all files", expect_that(resultsMatch, is_true()) }) -test_that(paste("getFileListing returns names of all direct children", +test_that(paste("getFileListing returns sorted names of all direct children", "if fullPath is set to FALSE"), { animal <- Subcollection$new("animal") @@ -47,7 +49,7 @@ test_that(paste("getFileListing returns names of all direct children", fish$add(shark) result <- animal$getFileListing(fullPath = FALSE) - expectedResult <- c("fish", "dog") + expectedResult <- c("dog", "fish") resultsMatch <- length(expectedResult) == length(result) && all(expectedResult == result) @@ -103,12 +105,10 @@ test_that(paste("add raises exception if passed argument is", test_that(paste("add post content to a REST service", "if subcollection belongs to a collection"), { - api <- Arvados$new("myToken", "myHostName") - api$setHttpClient(FakeHttpRequest$new()) - api$setHttpParser(FakeHttpParser$new()) - collectionContent <- c("animal", "animal/fish") fakeREST <- FakeRESTService$new(collectionContent) + + api <- Arvados$new("myToken", "myHostName") api$setRESTService(fakeREST) collection <- Collection$new(api, "myUUID") @@ -156,13 +156,10 @@ test_that("remove raises exception if passed argument is not character vector", test_that(paste("remove removes content from REST service", "if subcollection belongs to a collection"), { - api <- Arvados$new("myToken", "myHostName") - api$setHttpClient(FakeHttpRequest$new()) - api$setHttpParser(FakeHttpParser$new()) - collectionContent <- c("animal", "animal/fish", "animal/dog") - fakeREST <- FakeRESTService$new(collectionContent) + + api <- Arvados$new("myToken", "myHostName") api$setRESTService(fakeREST) collection <- Collection$new(api, "myUUID") animal <- collection$get("animal") @@ -265,17 +262,14 @@ test_that(paste("move raises exception if subcollection", test_that("move raises exception if new location contains content with the same name", { - api <- Arvados$new("myToken", "myHostName") - api$setHttpClient(FakeHttpRequest$new()) - api$setHttpParser(FakeHttpParser$new()) - collectionContent <- c("animal", "animal/fish", "animal/dog", "animal/fish/shark", "fish") - fakeREST <- FakeRESTService$new(collectionContent) + + api <- Arvados$new("myToken", "myHostName") api$setRESTService(fakeREST) collection <- Collection$new(api, "myUUID") fish <- collection$get("animal/fish") @@ -288,17 +282,14 @@ test_that("move raises exception if new location contains content with the same test_that(paste("move raises exception if newLocationInCollection", "parameter is invalid"), { - api <- Arvados$new("myToken", "myHostName") - api$setHttpClient(FakeHttpRequest$new()) - api$setHttpParser(FakeHttpParser$new()) - collectionContent <- c("animal", "animal/fish", "animal/dog", "animal/fish/shark", "ball") - fakeREST <- FakeRESTService$new(collectionContent) + + api <- Arvados$new("myToken", "myHostName") api$setRESTService(fakeREST) collection <- Collection$new(api, "myUUID") @@ -310,17 +301,14 @@ test_that(paste("move raises exception if newLocationInCollection", test_that("move moves subcollection inside collection tree", { - api <- Arvados$new("myToken", "myHostName") - api$setHttpClient(FakeHttpRequest$new()) - api$setHttpParser(FakeHttpParser$new()) - collectionContent <- c("animal", "animal/fish", "animal/dog", "animal/fish/shark", "ball") - fakeREST <- FakeRESTService$new(collectionContent) + + api <- Arvados$new("myToken", "myHostName") api$setRESTService(fakeREST) collection <- Collection$new(api, "myUUID") fish <- collection$get("animal/fish") @@ -344,14 +332,11 @@ test_that(paste("getSizeInBytes returns zero if subcollection", test_that(paste("getSizeInBytes delegates size calculation", "to REST service class"), { - api <- Arvados$new("myToken", "myHostName") - api$setHttpClient(FakeHttpRequest$new()) - api$setHttpParser(FakeHttpParser$new()) - collectionContent <- c("animal", "animal/fish") returnSize <- 100 - fakeREST <- FakeRESTService$new(collectionContent, returnSize) + + api <- Arvados$new("myToken", "myHostName") api$setRESTService(fakeREST) collection <- Collection$new(api, "myUUID") animal <- collection$get("animal")