Skip to content

Commit

Permalink
remind to restart R session
Browse files Browse the repository at this point in the history
ref #138
  • Loading branch information
wibeasley committed Jan 14, 2024
1 parent 305b853 commit db2dc90
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
4 changes: 2 additions & 2 deletions R/assert-version.R
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ assert_version_package <- function(

installation_message <-
if (1L <= nchar(installation_code)) {
" Install the package with `%s`." |>
" Install the package with `%s`. Afterwards, please restart the R session." |>
sprintf(installation_code)
} else {
""
" Afterwards, please restart the R session."
}

if (!package_is_installed) {
Expand Down
29 changes: 26 additions & 3 deletions tests/testthat/test-assert-version-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test_that("old minimum", {
expect_true(r)
})

test_that("minimum that throws an error", {
test_that("minimum that throws an error -base", {
expected_error_message <- "Your version of the `base` package is too old"
expect_error(
assert_version_package("base", "99.1.0"),
Expand All @@ -26,5 +26,28 @@ test_that("minimum that throws an error", {
expected_error_message
)
})
stop("TODO: test installation message for non-existent package.")
stop("TODO: test installation message for an old package.")
test_that("minimum that throws an error -tibble", {
expected_error_message <- "Your version of the `tibble` package is too old"
expect_error(
assert_version_package("tibble", "99.1.0"),
expected_error_message
)

expect_error(
assert_version_package("tibble", package_version("99.1.0")),
expected_error_message
)
})
test_that("missing package throws an error", {
expected_error_message <- "The package 'tibbleeee' not installed\\. Afterwards, please restart the R session\\."

expect_error(
assert_version_package("tibbleeee", "99.1.0"),
expected_error_message
)

expect_error(
assert_version_package("tibbleeee", "99.1.0"),
expected_error_message
)
})

0 comments on commit db2dc90

Please sign in to comment.