R/expect_snapshot_csv.R

Defines functions expect_snapshot_csv

Documented in expect_snapshot_csv

#' @title
#'   Helper function to perform snapshot testing for whole .CSV files.
#'
#' @description
#'   The \code{expect_snapshot_csv()} writes and compares new tibble to a
#'   .CSV file.
#'
#' @param name
#'   Name of the .CSV file.
#'
#' @param timber
#'   A tibble of timber.
#'
#' @export

expect_snapshot_csv <- function(name, timber) {
  name_ext <- paste0(
    name,
    ".csv"
  )
  testthat::announce_snapshot_file(name = name)

  path <- write_tibble_to_csv(timber, name)
  testthat::expect_snapshot_file(path, name_ext)
}
iAM-AMR/sawmill documentation built on June 30, 2024, 2:25 a.m.