tests/testthat/test-write_csvy.R

context("CSVY export using write_csvy()")
require("datasets")

test_that("Basic export to CSVY", {
    tmp <- tempfile()
    write_csvy(iris, tmp)
    suppressWarnings(expect_true(file.exists(tmp)))
    unlink(tmp)
})

test_that("Export to CSVY with separate yaml header", {
    tmp_csvy <- tempfile(fileext = ".csv")
    tmp_yaml <- tempfile(fileext = ".yaml")
    tmp_json <- tempfile(fileext = ".json")
    
    # write to yaml
    write_csvy(iris, file = tmp_csvy, metadata = tmp_yaml)
    suppressWarnings(expect_true(file.exists(tmp_csvy)))
    suppressWarnings(expect_true(file.exists(tmp_yaml)))
    unlink(tmp_csvy)
    unlink(tmp_yaml)
    
    # write to json
    write_csvy(iris, file = tmp_csvy, metadata = tmp_json)
    suppressWarnings(expect_true(file.exists(tmp_csvy)))
    suppressWarnings(expect_true(file.exists(tmp_json)))
    
    unlink(tmp_csvy)
    unlink(tmp_json)
})

Try the csvy package in your browser

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

csvy documentation built on May 2, 2019, 2:09 a.m.