Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Jan 3, 2021
1 parent e6e5ade commit b1460e4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/testthat/setup.R
@@ -0,0 +1 @@
suppressWarnings(requireNamespace("RSQLite", quietly = TRUE))
21 changes: 21 additions & 0 deletions 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)
})

0 comments on commit b1460e4

Please sign in to comment.