Skip to content

Commit

Permalink
Fix #451
Browse files Browse the repository at this point in the history
  • Loading branch information
chainsawriot committed Sep 10, 2024
1 parent 447ea1b commit 98a672b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
5 changes: 1 addition & 4 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,7 @@ escape_xml <- function(x, replacement = c("&amp;", "&quot;", "&lt;", "&gt;", "&a

.check_trust <- function(trust, format) {
if (is.null(trust)) {
lifecycle::deprecate_warn(
when = "1.0.3",
what = "import(trust = 'should be explicit for serialization formats')",
details = paste0("Missing `trust` will be set to FALSE by default for ", format, " in 2.0.0."))
warning("Missing `trust` will be set to FALSE by default for ", format, " in 2.0.0.", call. = FALSE)
trust <- TRUE ## Change this for version 2.0.0
}
if (isFALSE(trust)) {
Expand Down
8 changes: 4 additions & 4 deletions tests/testthat/test_trust.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ test_that("Deprecation of untrusted dump", {
withr::with_tempfile("iris_file", fileext = ".dump", code = {
export(iris, iris_file)
## expect deprecation to work
lifecycle::expect_deprecated(import(iris_file), regexp = "set to FALSE by default")
expect_warning(import(iris_file), regexp = "set to FALSE by default")
## expect false to error
expect_error(import(iris_file, trust = FALSE))
})
Expand All @@ -12,7 +12,7 @@ test_that("Deprecation of untrusted Rdata", {
withr::with_tempfile("iris_file", fileext = ".Rdata", code = {
export(iris, iris_file)
## expect deprecation to work
lifecycle::expect_deprecated(import(iris_file), regexp = "set to FALSE by default")
expect_warning(import(iris_file), regexp = "set to FALSE by default")
## expect false to error
expect_error(import(iris_file, trust = FALSE))
})
Expand All @@ -22,7 +22,7 @@ test_that("Deprecation of untrusted rds", {
withr::with_tempfile("iris_file", fileext = ".rds", code = {
export(iris, iris_file)
## expect deprecation to work
lifecycle::expect_deprecated(import(iris_file), regexp = "set to FALSE by default")
expect_warning(import(iris_file), regexp = "set to FALSE by default")
## expect false to error
expect_error(import(iris_file, trust = FALSE))
})
Expand Down Expand Up @@ -63,7 +63,7 @@ test_that("`trust` wont cause problems for other import methods", {
test_that("`trust` for import_list()", {
withr::with_tempfile("iris_file", fileext = ".rdata", code = {
export(iris, iris_file)
lifecycle::expect_deprecated(import_list(iris_file), regexp = "set to FALSE by default")
expect_warning(import_list(iris_file), regexp = "set to FALSE by default")
expect_silent(import_list(iris_file, trust = TRUE))
expect_error(import_list(iris_file, trust = FALSE))

Expand Down

0 comments on commit 98a672b

Please sign in to comment.