tests/testthat/test_configure_task.R

context("test_configure_task")

# create temporary directory
dir <- tempdir()

# create and save con
time <- Sys.time()
conf <- configure_task(dir_path = dir,
                       conf_descr = list(title = "my_title",
                                         description = "my_descr"),
                       fun_path = dir, # as an example
                       fun_name = "my_fun_name",
                       fun_args = list(x = 1,
                                       y = 0:4,
                                       z = iris),
                       priority = 1)


test_that("test outputs", {
  # output files
  conf_run_info <- conf$run_info
  conf_run_info$date_creation <- NULL
  expect_equal(conf_run_info, list(
    "date_start" = "N/A",
    "date_end" = "N/A",
    "priority" = 1,
    "status" = "waiting")
  )
  
  expect_equal(conf$descriptive, list(title = "my_title", description = "my_descr"))
  expect_equal(conf$`function`, list(
    "path" = gsub("\\", "/", dir, fixed = T),
    "name" = "my_fun_name")
  )
  
  expect_equal(c("x", "y", "z"), names(conf$args))
  
  expect_equal(list.files(conf$dir), c("conf.yml", "inputs"))
  
  expect_equal(readRDS(paste0(conf$dir, "inputs/y.RDS")), 0:4)
  
  expect_equal(readRDS(paste0(conf$dir, "inputs/z.RDS")), iris)
  
})

Try the shinybatch package in your browser

Any scripts or data that you put into this service are public.

shinybatch documentation built on June 30, 2021, 9:06 a.m.