tests/testthat/test-create_run_times_file.R

context("test-create_run_times_file")

test_that("use", {

  # Should create 'results/'run_times.csv'
  filename <- create_run_times_file(
    project_folder_name = raztr::get_raztr_path("razzo_project")
  )

  # File should be created
  expect_true(file.exists(filename))

  # OK: filename must end with 'run_times.csv'
  expect_true(
    length(
      grep(
        pattern = "run_times\\.csv$", filename, perl = TRUE, value = TRUE
      )
    ) > 0
  )
  # OK: should be in razzo_project/results folder
  # Use ..? to indicate one or two back- or normal slashes
  expect_true(
    length(
      grep(
        pattern = "razzo_project..?results..?",
        filename, perl = TRUE, value = TRUE
      )
    ) > 0
  )

})

test_that("abuse", {
  expect_error(
    create_run_times_file(project_folder_name = "nonsense"),
    "'project_folder_name' must end with 'razzo_project'"
  )
})
richelbilderbeek/razzo documentation built on March 10, 2021, 1:17 p.m.