R/test-helpers.R

Defines functions expect_file_exists expect_dir_exists

#' @noRd
expect_dir_exists <- function(object) {
  act <- testthat::quasi_label(rlang::enquo(object), arg = "object")

  testthat::expect(
    fs::dir_exists(act$val),
    sprintf(
      "\"%s\" in variable %s is not a path to an existing directory.",
      act$val, act$lab
    )
  )

  invisible(act$val)
}

#' @noRd
expect_file_exists <- function(object) {
  act <- testthat::quasi_label(rlang::enquo(object), arg = "object")

  testthat::expect(
    fs::file_exists(act$val),
    sprintf(
      "\"%s\" in variable %s is not a path to an existing file.",
      act$val, act$lab
    )
  )

  invisible(act$val)
}
AdrienLeGuillou/slurmworkflow documentation built on Jan. 13, 2022, 5:13 p.m.