tests/testthat/test-write_spice.R

context("write_spice")

test_that("write spice creates a dataspice.json in the right place", {
  tmp <- tempdir()
  on.exit(unlink(tmp, recursive = TRUE))

  unlink(file.path(tmp, "metadata"), recursive = TRUE)
  dir.create(file.path(tmp, "metadata"))

  files_to_copy <- dir(system.file("metadata-tables", package = "dataspice"),
                       pattern = ".csv",
                       full.names = TRUE)

  lapply(files_to_copy, function(path) {
    file.copy(path, file.path(tmp, "metadata", basename(path)),
              overwrite = TRUE)
  })

  write_spice(file.path(tmp, "metadata"))
  dataspice_path <- file.path(tmp, "metadata", "dataspice.json")

  expect_true(file.exists(dataspice_path))
  expect_true(file.size(dataspice_path) > 0)
})

Try the dataspice package in your browser

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

dataspice documentation built on May 17, 2021, 1:09 a.m.