Add unit test 20295-fix-collection-tree-caching-bug
authorKonrad Rudolph <konrad.rudolph@gmail.com>
Thu, 30 Mar 2023 17:25:25 +0000 (19:25 +0200)
committerKonrad Rudolph <konrad.rudolph@gmail.com>
Fri, 31 Mar 2023 07:07:49 +0000 (09:07 +0200)
Arvados-DCO-1.1-Signed-off-by: Konrad Rudolph <konrad.rudolph@gmail.com>

sdk/R/tests/testthat/fakes/FakeRESTService.R
sdk/R/tests/testthat/test-Collection.R

index 095392661afc014ae438b4903e5b99026ee68fa8..255e64d1b4bf88e8542a67cc00bf10b5a5aa498b 100644 (file)
@@ -146,7 +146,11 @@ FakeRESTService <- R6::R6Class(
         getCollectionContent = function(uuid, relativePath = NULL)
         {
             self$getCollectionContentCallCount <- self$getCollectionContentCallCount + 1
-            self$collectionContent
+            if (!is.null(relativePath)) {
+                self$collectionContent[startsWith(self$collectionContent, relativePath)]
+            } else {
+                self$collectionContent
+            }
         },
 
         getResourceSize = function(uuid, relativePathToResource)
index 20a2ecf05b120bb769d7f0b8d01c007099638516..3023a1b23fafcf01c28fda05e775cbe471927e04 100644 (file)
@@ -239,6 +239,12 @@ test_that("get returns arvados file or subcollection from internal tree structur
 
     expect_true(fishIsNotNull)
     expect_that(fish$getName(), equals("fish"))
+
+    ball <- collection$get("ball")
+    ballIsNotNull <- !is.null(ball)
+
+    expect_true(ballIsNotNull)
+    expect_that(ball$getName(), equals("ball"))
 })
 
 test_that(paste("copy copies content to a new location inside file tree",