test_that("constructor raises error if file name is empty string", {
expect_that(ArvadosFile$new(""), throws_error("Invalid name."))
-})
+})
test_that("getFileListing always returns file name", {
dog <- ArvadosFile$new("dog")
expect_that(dog$getFileListing(), equals("dog"))
-})
+})
test_that("get always returns NULL", {
dog <- ArvadosFile$new("dog")
-
+
responseIsNull <- is.null(dog$get("something"))
expect_that(responseIsNull, is_true())
-})
+})
test_that("getFirst always returns NULL", {
dog <- ArvadosFile$new("dog")
-
+
responseIsNull <- is.null(dog$getFirst())
expect_that(responseIsNull, is_true())
-})
+})
test_that(paste("getSizeInBytes returns zero if arvadosFile",
"is not part of a collection"), {
dog <- ArvadosFile$new("dog")
expect_that(dog$getSizeInBytes(), equals(0))
-})
+})
test_that(paste("getSizeInBytes delegates size calculation",
"to REST service class"), {
resourceSize <- fish$getSizeInBytes()
expect_that(resourceSize, equals(100))
-})
+})
test_that("getRelativePath returns path relative to the tree root", {
fish$add(shark)
expect_that(shark$getRelativePath(), equals("animal/fish/shark"))
-})
+})
test_that("read raises exception if file doesn't belong to a collection", {
expect_that(dog$read(),
throws_error("ArvadosFile doesn't belong to any collection."))
-})
+})
test_that("read raises exception offset or length is negative number", {
throws_error("Offset and length must be positive values."))
expect_that(fish$read(contentType = "text", offset = -1, length = -1),
throws_error("Offset and length must be positive values."))
-})
+})
test_that("read delegates reading operation to REST service class", {
api$setRESTService(fakeREST)
collection <- Collection$new(api, "myUUID")
fish <- collection$get("animal/fish")
-
+
fileContent <- fish$read("text")
expect_that(fileContent, equals("my file"))
expect_that(fakeREST$readCallCount, equals(1))
-})
+})
test_that(paste("connection delegates connection creation ro RESTService class",
- "which returns curl connection opened in read mode when",
+ "which returns curl connection opened in read mode when",
"'r' of 'rb' is passed as argument"), {
collectionContent <- c("animal", "animal/fish")
connection <- fish$connection("r")
expect_that(fakeREST$getConnectionCallCount, equals(1))
-})
+})
test_that(paste("connection returns textConnection opened",
"in write mode when 'w' is passed as argument"), {
expect_that(writeResult[1], equals("file"))
expect_that(writeResult[2], equals("content"))
-})
+})
test_that("flush sends data stored in a connection to a REST server", {
fish$flush()
expect_that(fakeREST$writeBuffer, equals("file content"))
-})
+})
test_that("write raises exception if file doesn't belong to a collection", {
expect_that(dog$write(),
throws_error("ArvadosFile doesn't belong to any collection."))
-})
+})
test_that("write delegates writing operation to REST service class", {
api$setRESTService(fakeREST)
collection <- Collection$new(api, "myUUID")
fish <- collection$get("animal/fish")
-
+
fileContent <- fish$write("new file content")
expect_that(fakeREST$writeBuffer, equals("new file content"))
-})
+})
test_that(paste("move raises exception if arvados file",
"doesn't belong to any collection"), {
expect_that(animal$move("new/location"),
throws_error("ArvadosFile doesn't belong to any collection"))
-})
+})
test_that(paste("move raises exception if newLocationInCollection",
"parameter is invalid"), {
expect_that(dog$move("objects/dog"),
throws_error("Unable to get destination subcollection"))
-})
+})
test_that("move raises exception if new location contains content with the same name", {
expect_that(dog$move("dog"),
throws_error("Destination already contains content with same name."))
-})
+})
test_that("move moves arvados file inside collection tree", {