context("ArvadosFile")
+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")
returnSize <- 100
fakeREST <- FakeRESTService$new(collectionContent, returnSize)
- api <- Arvados$new("myToken", "myHostName")
- api$setRESTService(fakeREST)
- collection <- Collection$new(api, "myUUID")
+ collection <- Collection$new("fakeUUID")
+ collection$setRESTService(fakeREST)
fish <- collection$get("animal/fish")
resourceSize <- fish$getSizeInBytes()
collectionContent <- c("animal", "animal/fish")
fakeREST <- FakeRESTService$new(collectionContent)
- api <- Arvados$new("myToken", "myHostName")
- api$setRESTService(fakeREST)
- collection <- Collection$new(api, "myUUID")
+ collection <- Collection$new("fakeUUID")
+ collection$setRESTService(fakeREST)
fish <- collection$get("animal/fish")
expect_that(fish$read(contentType = "text", offset = -1),
readContent <- "my file"
fakeREST <- FakeRESTService$new(collectionContent, readContent)
- api <- Arvados$new("myToken", "myHostName")
- api$setRESTService(fakeREST)
- collection <- Collection$new(api, "myUUID")
+ collection <- Collection$new("fakeUUID")
+ collection$setRESTService(fakeREST)
fish <- collection$get("animal/fish")
fileContent <- fish$read("text")
expect_that(fakeREST$readCallCount, equals(1))
})
-test_that(paste("connect returns textConnection opened",
- "in read mode when 'r' is passed as argument"), {
+test_that(paste("connection delegates connection creation ro RESTService class",
+ "which returns curl connection opened in read mode when",
+ "'r' of 'rb' is passed as argument"), {
collectionContent <- c("animal", "animal/fish")
- readContent <- "file content"
- fakeREST <- FakeRESTService$new(collectionContent, readContent)
+ fakeREST <- FakeRESTService$new(collectionContent)
- api <- Arvados$new("myToken", "myHostName")
- api$setRESTService(fakeREST)
- collection <- Collection$new(api, "myUUID")
+ collection <- Collection$new("fakeUUID")
+ collection$setRESTService(fakeREST)
fish <- collection$get("animal/fish")
connection <- fish$connection("r")
- expect_that(readLines(connection), equals("file content"))
+ expect_that(fakeREST$getConnectionCallCount, equals(1))
})
-test_that(paste("connect returns textConnection opened",
+test_that(paste("connection returns textConnection opened",
"in write mode when 'w' is passed as argument"), {
-
collectionContent <- c("animal", "animal/fish")
fakeREST <- FakeRESTService$new(collectionContent)
- api <- Arvados$new("myToken", "myHostName")
- api$setRESTService(fakeREST)
- collection <- Collection$new(api, "myUUID")
+ collection <- Collection$new("fakeUUID")
+ collection$setRESTService(fakeREST)
fish <- collection$get("animal/fish")
connection <- fish$connection("w")
collectionContent <- c("animal", "animal/fish")
fakeREST <- FakeRESTService$new(collectionContent)
- api <- Arvados$new("myToken", "myHostName")
- api$setRESTService(fakeREST)
- collection <- Collection$new(api, "myUUID")
+ collection <- Collection$new("fakeUUID")
+ collection$setRESTService(fakeREST)
fish <- collection$get("animal/fish")
connection <- fish$connection("w")
collectionContent <- c("animal", "animal/fish")
fakeREST <- FakeRESTService$new(collectionContent)
- api <- Arvados$new("myToken", "myHostName")
- api$setRESTService(fakeREST)
- collection <- Collection$new(api, "myUUID")
+ collection <- Collection$new("fakeUUID")
+ collection$setRESTService(fakeREST)
fish <- collection$get("animal/fish")
fileContent <- fish$write("new file content")
"animal/dog",
"animal/fish/shark",
"ball")
- fakeREST <- FakeRESTService$new(collectionContent)
- api <- Arvados$new("myToken", "myHostName")
- api$setRESTService(fakeREST)
+ fakeREST <- FakeRESTService$new(collectionContent)
- collection <- Collection$new(api, "myUUID")
+ collection <- Collection$new("fakeUUID")
+ collection$setRESTService(fakeREST)
dog <- collection$get("animal/dog")
expect_that(dog$move("objects/dog"),
"animal/dog",
"animal/fish/shark",
"dog")
+
fakeREST <- FakeRESTService$new(collectionContent)
- api <- Arvados$new("myToken", "myHostName")
- api$setRESTService(fakeREST)
- collection <- Collection$new(api, "myUUID")
+ collection <- Collection$new("fakeUUID")
+ collection$setRESTService(fakeREST)
dog <- collection$get("animal/dog")
expect_that(dog$move("dog"),
"animal/dog",
"animal/fish/shark",
"ball")
+
fakeREST <- FakeRESTService$new(collectionContent)
- api <- Arvados$new("myToken", "myHostName")
- api$setRESTService(fakeREST)
- collection <- Collection$new(api, "myUUID")
+ collection <- Collection$new("fakeUUID")
+ collection$setRESTService(fakeREST)
dog <- collection$get("animal/dog")
dog$move("dog")