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."
  )
})
pik-piam/citation documentation built on Jan. 31, 2024, 10 a.m.