[ARVADOS] updated: 1.1.2-115-gb5c2d27

Git user git at public.curoverse.com
Fri Jan 12 09:53:33 EST 2018


Summary of changes:
 sdk/R/tests/testthat/test-CollectionTree.R | 102 +++++++++++++++++++++++++++++
 1 file changed, 102 insertions(+)
 create mode 100644 sdk/R/tests/testthat/test-CollectionTree.R

       via  b5c2d27b55ff8490818548bc077975fbf37b3a1f (commit)
      from  68d1c59bc33df1b002754b958b6887896f2a40d5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit b5c2d27b55ff8490818548bc077975fbf37b3a1f
Author: Fuad Muhic <fmuhic at capeannenterprises.com>
Date:   Fri Jan 12 15:52:55 2018 +0100

    Added unit tests for CollectionTree class
    
    Arvados-DCO-1.1-Signed-off-by: Fuad Muhic <fmuhic at capeannenterprises.com>

diff --git a/sdk/R/tests/testthat/test-CollectionTree.R b/sdk/R/tests/testthat/test-CollectionTree.R
new file mode 100644
index 0000000..40551a2
--- /dev/null
+++ b/sdk/R/tests/testthat/test-CollectionTree.R
@@ -0,0 +1,102 @@
+context("CollectionTree")
+
+test_that("Creates file tree from character array properly", {
+
+    collection <- "myCollection"
+    characterArray <- c("animal", 
+                        "animal/dog",
+                        "boat")
+
+    collectionTree <- CollectionTree$new(characterArray, collection)
+
+    root   <- collectionTree$getTree()
+    animal <- collectionTree$getElement("animal")
+    dog    <- collectionTree$getElement("animal/dog")
+    boat   <- collectionTree$getElement("boat")
+
+    rootHasNoParent             <- is.null(root$getParent())
+    rootIsOfTypeSubcollection   <- "Subcollection" %in% class(root)
+    animalIsOfTypeSubcollection <- "Subcollection" %in% class(animal)
+    dogIsOfTypeArvadosFile      <- "ArvadosFile" %in% class(dog)
+    boatIsOfTypeArvadosFile     <- "ArvadosFile" %in% class(boat)
+    animalsParentIsRoot         <- animal$getParent()$getName() == root$getName()
+    animalContainsDog           <- animal$getFirst()$getName() == dog$getName()
+    dogsParentIsAnimal          <- dog$getParent()$getName() == animal$getName()
+    boatsParentIsRoot           <- boat$getParent()$getName() == root$getName()
+
+    allElementsBelongToSameCollection <- root$getCollection()   == "myCollection" &&
+                                         animal$getCollection() == "myCollection" &&
+                                         dog$getCollection()    == "myCollection" &&
+                                         boat$getCollection()   == "myCollection"
+
+    expect_that(root$getName(), equals(""))
+    expect_that(rootIsOfTypeSubcollection, is_true())
+    expect_that(rootHasNoParent, is_true())
+    expect_that(animalIsOfTypeSubcollection, is_true())
+    expect_that(animalsParentIsRoot, is_true())
+    expect_that(animalContainsDog, is_true())
+    expect_that(dogIsOfTypeArvadosFile, is_true())
+    expect_that(dogsParentIsAnimal, is_true())
+    expect_that(boatIsOfTypeArvadosFile, is_true())
+    expect_that(boatsParentIsRoot, is_true())
+    expect_that(allElementsBelongToSameCollection, is_true())
+}) 
+
+test_that("getElement returns element from tree if element exists on specified path", {
+
+    collection <- "myCollection"
+    characterArray <- c("animal", 
+                        "animal/dog",
+                        "boat")
+
+    collectionTree <- CollectionTree$new(characterArray, collection)
+
+    dog <- collectionTree$getElement("animal/dog")
+
+    expect_that(dog$getName(), equals("dog"))
+}) 
+
+test_that("getElement returns NULL from tree if element doesn't exists on specified path", {
+
+    collection <- "myCollection"
+    characterArray <- c("animal", 
+                        "animal/dog",
+                        "boat")
+
+    collectionTree <- CollectionTree$new(characterArray, collection)
+
+    fish <- collectionTree$getElement("animal/fish")
+    fishIsNULL <- is.null(fish)
+
+    expect_that(fishIsNULL, is_true())
+}) 
+
+test_that("getElement trims ./ from start of relativePath", {
+
+    collection <- "myCollection"
+    characterArray <- c("animal", 
+                        "animal/dog",
+                        "boat")
+
+    collectionTree <- CollectionTree$new(characterArray, collection)
+
+    dog <- collectionTree$getElement("animal/dog")
+    dogWithDotSlash <- collectionTree$getElement("./animal/dog")
+
+    expect_that(dogWithDotSlash$getName(), equals(dog$getName()))
+}) 
+
+test_that("getElement trims / from end of relativePath", {
+
+    collection <- "myCollection"
+    characterArray <- c("animal", 
+                        "animal/dog",
+                        "boat")
+
+    collectionTree <- CollectionTree$new(characterArray, collection)
+
+    animal <- collectionTree$getElement("animal")
+    animalWithSlash <- collectionTree$getElement("animal/")
+
+    expect_that(animalWithSlash$getName(), equals(animal$getName()))
+}) 

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list