X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/0488e81c85948faa6a14ca437d9e594d91bcbbd8..f98e0188777b3e2d229c968824b3e64307dae4e6:/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 401b086a0c..b2b0bc9ccf 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) @@ -71,6 +73,15 @@ test_that("add adds content to inside collection tree", { expect_that(animalContainsDog, is_true()) }) +test_that("add raises exception if content name is empty string", { + + animal <- Subcollection$new("animal") + rootFolder <- Subcollection$new("") + + expect_that(animal$add(rootFolder), + throws_error("Content has invalid name.", fixed = TRUE)) +}) + test_that(paste("add raises exception if ArvadosFile/Subcollection", "with same name already exists in the subcollection"), { @@ -342,4 +353,4 @@ test_that(paste("getSizeInBytes delegates size calculation", resourceSize <- animal$getSizeInBytes() expect_that(resourceSize, equals(100)) -}) +})