diff --git a/tests/testthat/setup.R b/tests/testthat/setup.R new file mode 100644 index 00000000..bc409a0b --- /dev/null +++ b/tests/testthat/setup.R @@ -0,0 +1 @@ +suppressWarnings(requireNamespace("RSQLite", quietly = TRUE)) diff --git a/tests/testthat/test-table-insert.R b/tests/testthat/test-table-insert.R new file mode 100644 index 00000000..d579bea9 --- /dev/null +++ b/tests/testthat/test-table-insert.R @@ -0,0 +1,21 @@ +test_that("appending with zero columns throws a dedicated error (#313)", { + skip_if_not_installed("RSQLite") + + db <- dbConnect(RSQLite::SQLite(), ":memory:") + on.exit(dbDisconnect(db)) + + dbExecute(db, "create table T(n integer primary key)") + expect_error(dbAppendTable(db, "T", data.frame()), "column") +}) + +test_that("appending with zero columns throws a dedicated error (#336)", { + skip_if_not_installed("RSQLite") + + library(RSQLite) + a <- data.frame(sep = c(1, 2, 3)) + con <- dbConnect(SQLite()) + on.exit(dbDisconnect(con)) + + dbWriteTable(con, "a", a) + expect_equal(dbReadTable(con, "a"), a) +})