tests/testthat/test-cff2r.R

test_that("r2cff generally works", {
  citationFile <- system.file("CFF-CITATION.cff", package = "citation")
  testthat::skip_if(!file.exists(citationFile))
  tempPath <- withr::local_tempdir()
  exportName <- "testExport"
  expect_output(cff2r(citationFile), "Authors@R")
  expect_message(
    cff2r(citationFile, export = TRUE, outname = exportName, outpath = tempPath),
    paste("Saved as", normalizePath(file.path(tempPath, exportName))),
    fixed = TRUE
  )
  expect_message(
    cff2r(citationFile, export = TRUE, outname = exportName, outpath = tempPath),
    "testExport already exists. Saving under a different filename."
  )
  expect_message(
    cff2r(
      citationFile, export = TRUE, outname = exportName, outpath = tempPath,
      overwrite = TRUE
    ),
    "testExport already exists. Overwriting as requested."
  )
})

Try the citation package in your browser

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

citation documentation built on March 31, 2023, 11:31 p.m.