Skip to content

Commit

Permalink
test: Run DBItest for SQLite as part of the checks here
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Dec 16, 2023
1 parent f79cd24 commit ee1cc3a
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
^CRAN-SUBMISSION$
^\.vscode$
^\.aviator/config\.yml$
^tests/testthat/helper-dev\.R$
16 changes: 16 additions & 0 deletions tests/testthat/helper-dev.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
if (dir.exists("../../../RSQLite")) {
writeLines(
c(
"# Generated by helper-dev.R, do not edit by hand",
"",
"skip_if_not_installed(\"RSQLite\")",
"",
"# helper-DBItest.R",
readLines("../../../RSQLite/tests/testthat/helper-DBItest.R"),
"",
"# test-DBItest.R",
readLines("../../../RSQLite/tests/testthat/test-DBItest.R")
),
"test-DBItest.R"
)
}
35 changes: 35 additions & 0 deletions tests/testthat/test-DBItest.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generated by helper-dev.R, do not edit by hand

skip_if_not_installed("RSQLite")

# helper-DBItest.R
# Also copied into DBI
tryCatch(skip = function(e) message(conditionMessage(e)), {
skip_on_cran()
skip_if_not_installed("DBItest")

DBItest::make_context(
RSQLite::SQLite(),
list(dbname = tempfile("DBItest", fileext = ".sqlite")),
tweaks = DBItest::tweaks(
dbitest_version = "1.7.2",
constructor_relax_args = TRUE,
placeholder_pattern = c("?", "$1", "$name", ":name"),
date_cast = function(x) paste0("'", x, "'"),
time_cast = function(x) paste0("'", x, "'"),
timestamp_cast = function(x) paste0("'", x, "'"),
logical_return = function(x) as.integer(x),
date_typed = FALSE,
time_typed = FALSE,
timestamp_typed = FALSE
),
name = "RSQLite"
)
})

# test-DBItest.R
# Also copied into DBI
skip_on_cran()
skip_if_not_installed("DBItest")

DBItest::test_all()

0 comments on commit ee1cc3a

Please sign in to comment.