Skip to content

Commit

Permalink
Merge pull request #487 from r-dbi/f-clean-dbitest
Browse files Browse the repository at this point in the history
chore: Clean up DBItest call
  • Loading branch information
aviator-app[bot] authored Dec 17, 2023
2 parents 1e46bc8 + f82ea19 commit a71ca9e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 53 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Imports:
rlang
Suggests:
callr,
DBItest (>= 1.7.2.9001),
DBItest (>= 1.7.3),
gert,
gh,
hms,
Expand Down
67 changes: 22 additions & 45 deletions tests/testthat/helper-DBItest.R
Original file line number Diff line number Diff line change
@@ -1,46 +1,23 @@
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
# Also copied into DBI
tryCatch(skip = function(e) message(conditionMessage(e)), {
skip_on_cran()
skip_if_not_installed("DBItest")

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"
)
}
}
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"
)
})
10 changes: 3 additions & 7 deletions tests/testthat/test-DBItest.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Also copied into DBI
skip_on_cran()
skip_if_not_installed("DBItest")

if (identical(Sys.getenv("NOT_CRAN"), "true")) {
if (packageVersion("DBItest") >= "1.6.0") {
DBItest::test_all()
} else {
DBItest::test_all(skip = c(default_skip, "roundtrip_raw", "roundtrip_blob"))
}
}
DBItest::test_all()

0 comments on commit a71ca9e

Please sign in to comment.