tests/testthat/test01-caching.R

context("test01-caching")

test_that("Check that cache is automatically updated while registering or deleting cached entities", {
  # cat("# Now connect to scidb\n")
  e0 = tryCatch({rg_connect()}, error = function(e) {e})
  if (!("error" %in% class(e0))) { # do not run this on EE installs, mainly targeted for Travis
    init_db(arrays_to_init = get_entity_names(), force = TRUE, silent = TRUE)
    # Get the existing ontology fields
    ont1 = get_ontology()
    
    # Register a dummy ontology field
    dummy_val = "dummy"
    new_ont_id = register_ontology_term(df = data.frame(term = dummy_val, source_name = "...", source_version = "..."))
    # Check that cache is increased by 1 element
    ont2 = get_ontology()
    expect_equal(nrow(ont2), nrow(ont1) + 1)
    
    # Verify that the dummy term was uploaded properly
    expect_true(dummy_val %in% get_ontology()$term)
    
    # Clean-up
    init_db(arrays_to_init = get_entity_names(), force = TRUE, silent = TRUE)
  }
})
Paradigm4/revealgenomics documentation built on April 7, 2020, 2:01 a.m.