tests/testthat/test-export.R

library(testthat)
library(mdbr)

test_that("tables can be exported as strings", {
  skip_on_cran()
  skip_if_not(has_mdb_tools())
  dat <- export_mdb(mdb_example(), "Airlines", output = TRUE)
  expect_type(dat, "character")
  expect_length(dat, 1)
})

test_that("tables can be exported to file", {
  skip_on_cran()
  skip_if_not(has_mdb_tools())
  tmp <- tempfile()
  dat <- export_mdb(mdb_example(), "Airlines", output = tmp)
  expect_true(file.exists(tmp))
  expect_equal(file.size(tmp), 450)
})

test_that("tables can be exported without escape", {
  skip_on_cran()
  skip_if_not(has_mdb_tools())
  dat <- export_mdb(
    file = mdb_example(),
    table = "Airlines",
    output = TRUE,
    quote_escape = FALSE
  )
  expect_type(dat, "character")
  expect_length(dat, 1)
})

test_that("exporting errors without table name", {
  skip_on_cran()
  skip_if_not(has_mdb_tools())
  expect_error(export_mdb(mdb_example()))
})

Try the mdbr package in your browser

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

mdbr documentation built on May 29, 2024, 7:27 a.m.