| 1 |
|
| 2 |
test_that("renv.settings can be used to provide defaults", { |
| 3 |
|
| 4 |
renv_tests_scope() |
| 5 |
expect_equal(settings$snapshot.type(), "implicit") |
| 6 |
|
| 7 |
# project is not yet initialized, so defaults can be used |
| 8 |
local({ |
| 9 |
renv_scope_options(renv.settings.snapshot.type = "all") |
| 10 |
expect_equal(settings$snapshot.type(), "all") |
| 11 |
}) |
| 12 |
|
| 13 |
local({ |
| 14 |
renv_scope_options(renv.settings = list(snapshot.type = "all")) |
| 15 |
expect_equal(settings$snapshot.type(), "all") |
| 16 |
}) |
| 17 |
|
| 18 |
}) |
| 19 |
|
| 20 |
test_that("non-persistent settings exist in R session; not in file", { |
| 21 |
|
| 22 |
renv_tests_scope() |
| 23 |
expect_equal(settings$snapshot.type(), "implicit") |
| 24 |
|
| 25 |
project <- getwd() |
| 26 |
path <- "renv/settings.json" |
| 27 |
before <- renv_settings_read_impl(path) |
| 28 |
settings$snapshot.type("all", persist = FALSE) |
| 29 |
after <- renv_settings_read_impl(path) |
| 30 |
|
| 31 |
expect_equal(before, after) |
| 32 |
expect_equal(settings$snapshot.type(), "all") |
| 33 |
|
| 34 |
settings$ignored.packages("dplyr", persist = TRUE) |
| 35 |
|
| 36 |
settings <- renv_settings_get(project) |
| 37 |
persisted <- renv_settings_read_impl(path) |
| 38 |
|
| 39 |
# TODO |
| 40 |
settings$ppm.ignored.urls <- persisted$ppm.ignored.urls <- NULL |
| 41 |
|
| 42 |
expect_mapequal(settings, persisted) |
| 43 |
|
| 44 |
}) |
| 45 |
|
| 46 |
test_that("users can request specific versions of R for lockfile", { |
| 47 |
|
| 48 |
renv_tests_scope() |
| 49 |
renv_scope_options(renv.settings.r.version = "4.0") |
| 50 |
|
| 51 |
init() |
| 52 |
|
| 53 |
lockfile <- renv_lockfile_load(getwd()) |
| 54 |
expect_identical(lockfile$R$Version, "4.0") |
| 55 |
|
| 56 |
}) |
| 57 |
|
| 58 |
test_that("project settings are migrated from dcf to json", { |
| 59 |
|
| 60 |
project <- renv_tests_scope() |
| 61 |
init() |
| 62 |
|
| 63 |
settings <- heredoc(" |
| 64 |
bioconductor.version: 3.16 |
| 65 |
external.libraries: |
| 66 |
ignored.packages: |
| 67 |
package.dependency.fields: Imports, Depends, LinkingTo |
| 68 |
r.version: |
| 69 |
snapshot.type: implicit |
| 70 |
use.cache: TRUE |
| 71 |
vcs.ignore.cellar: TRUE |
| 72 |
vcs.ignore.library: TRUE |
| 73 |
vcs.ignore.local: TRUE |
| 74 |
") |
| 75 |
|
| 76 |
writeLines(settings, con = "renv/settings.dcf") |
| 77 |
old <- renv_settings_read(file.path(project, "renv/settings.dcf")) |
| 78 |
unlink("renv/settings.json") |
| 79 |
|
| 80 |
renv_settings_migrate(project) |
| 81 |
expect_true(file.exists("renv/settings.json")) |
| 82 |
new <- renv_settings_read(file.path(project, "renv/settings.json")) |
| 83 |
|
| 84 |
# TODO |
| 85 |
old$ppm.ignored.urls <- new$ppm.ignored.urls <- NULL |
| 86 |
|
| 87 |
expect_mapequal(old, new) |
| 88 |
|
| 89 |
}) |
| 90 |
|
| 91 |
test_that("a settings global option is handled correctly", { |
| 92 |
renv_tests_scope() |
| 93 |
renv_scope_options(renv.settings = list(ignored.packages = "odbc")) |
| 94 |
expect_equal(settings$ignored.packages(), "odbc") |
| 95 |
expect_null(settings$bioconductor.version()) |
| 96 |
}) |