From f82ea19183d55f0e6ac9873b0bfc2cbdc7d29140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kirill=20M=C3=BCller?= Date: Sat, 16 Dec 2023 17:23:59 +0100 Subject: [PATCH] chore: Clean up DBItest call --- DESCRIPTION | 2 +- tests/testthat/helper-DBItest.R | 67 +++++++++++---------------------- tests/testthat/test-DBItest.R | 10 ++--- 3 files changed, 26 insertions(+), 53 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index b913c1ffe..ac1986b07 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -42,7 +42,7 @@ Imports: rlang Suggests: callr, - DBItest (>= 1.7.2.9001), + DBItest (>= 1.7.3), gert, gh, hms, diff --git a/tests/testthat/helper-DBItest.R b/tests/testthat/helper-DBItest.R index e725601dc..eb78496a7 100644 --- a/tests/testthat/helper-DBItest.R +++ b/tests/testthat/helper-DBItest.R @@ -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" + ) +}) diff --git a/tests/testthat/test-DBItest.R b/tests/testthat/test-DBItest.R index edc12b645..7afcda05a 100644 --- a/tests/testthat/test-DBItest.R +++ b/tests/testthat/test-DBItest.R @@ -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()