Skip to content

Commit

Permalink
test: Skip DBItest tests if not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Oct 31, 2023
1 parent dbfaa1f commit 3707589
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 41 deletions.
84 changes: 43 additions & 41 deletions tests/testthat/helper-DBItest.R
Original file line number Diff line number Diff line change
@@ -1,44 +1,46 @@
default_skip <-
c(
if (packageVersion("DBItest") < "1.7.1.9004") "column_info_consistent", # https://github.com/r-dbi/DBItest/issues/181
if (rlang::is_installed("DBItest")) {
default_skip <-
c(
if (packageVersion("DBItest") < "1.7.1.9004") "column_info_consistent", # https://github.com/r-dbi/DBItest/issues/181

NULL
)
NULL
)

if (packageVersion("DBItest") >= "1.6.0") {
DBItest::make_context(
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",
default_skip = default_skip
)
} else {
DBItest::make_context(
SQLite(),
list(dbname = tempfile("DBItest", fileext = ".sqlite")),
tweaks = DBItest::tweaks(
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"
)
if (packageVersion("DBItest") >= "1.6.0") {
DBItest::make_context(
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",
default_skip = default_skip
)
} else {
DBItest::make_context(
SQLite(),
list(dbname = tempfile("DBItest", fileext = ".sqlite")),
tweaks = DBItest::tweaks(
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"
)
}
}
2 changes: 2 additions & 0 deletions tests/testthat/test-DBItest.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
skip_if_not_installed("DBItest")

if (identical(Sys.getenv("NOT_CRAN"), "true")) {
if (packageVersion("DBItest") >= "1.6.0") {
DBItest::test_all()
Expand Down

0 comments on commit 3707589

Please sign in to comment.