tests/testthat/test-ignore.R

context("ignore")

test_that("use_ignore works", {
  file <- system.file("extdata", "tests", "subsetCars.Rmd",
                      package = "DataPackageR"
  )
  local({
    tempdir <- withr::local_tempdir()
    expect_null(
      datapackage_skeleton(
        name = "subsetCars",
        path = tempdir,
        code_files = c(file),
        force = TRUE,
        r_object_names = c("cars_over_20")
      )
    )
    use_ignore(file = "mydata.csv", path = file.path("inst", "extdata"))
    expect_true(
      'mydata.csv' %in% readLines(
        file.path(tempdir, 'subsetCars', 'inst', 'extdata', '.gitignore')
      )
    )
    expect_true(
      '^inst/extdata/mydata\\.csv$' %in% readLines(
        file.path(tempdir, 'subsetCars', '.Rbuildignore')
      )
    )
    expect_message(use_ignore(),"No file name provided to ignore.")
  })
})

Try the DataPackageR package in your browser

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

DataPackageR documentation built on May 29, 2024, 9:15 a.m.