| 1 |
|
| 2 |
test_that("hydrate does not change library paths", { |
| 3 |
|
| 4 |
renv_tests_scope() |
| 5 |
|
| 6 |
lib <- renv_scope_tempfile() |
| 7 |
ensure_directory(lib) |
| 8 |
.libPaths(lib) |
| 9 |
|
| 10 |
before <- .libPaths() |
| 11 |
hydrate() |
| 12 |
after <- .libPaths() |
| 13 |
|
| 14 |
expect_identical(before, after) |
| 15 |
|
| 16 |
}) |
| 17 |
|
| 18 |
test_that("hydrate(update = FALSE) does not update older packages", { |
| 19 |
|
| 20 |
renv_tests_scope("bread") |
| 21 |
init() |
| 22 |
|
| 23 |
# set up project with older version of bread |
| 24 |
install("[email protected]") |
| 25 |
|
| 26 |
# add dependency on toast |
| 27 |
writeLines("library(toast)", con = "deps2.R") |
| 28 |
|
| 29 |
# set up library for hydration |
| 30 |
sourcelib <- renv_scope_tempfile("renv-source-") |
| 31 |
ensure_directory(sourcelib) |
| 32 |
install("toast", library = sourcelib) |
| 33 |
|
| 34 |
# try hydrating without update |
| 35 |
expect_false(renv_package_installed("toast")) |
| 36 |
hydrate(sources = sourcelib, update = FALSE) |
| 37 |
expect_true(renv_package_installed("toast")) |
| 38 |
expect_true(renv_package_version("toast") == "1.0.0") |
| 39 |
expect_true(renv_package_version("bread") == "0.1.0") |
| 40 |
|
| 41 |
# try hydrating with update |
| 42 |
hydrate(sources = sourcelib, update = TRUE) |
| 43 |
expect_true(renv_package_version("bread") == "1.0.0") |
| 44 |
|
| 45 |
}) |
| 46 |
|
| 47 |
test_that("hydrate succeeds when package installed into user library", { |
| 48 |
|
| 49 |
# use alternate (empty) cache for this test |
| 50 |
cachedir <- renv_scope_tempfile("renv-cache-") |
| 51 |
ensure_directory(cachedir) |
| 52 |
renv_scope_envvars(RENV_PATHS_CACHE = cachedir) |
| 53 |
|
| 54 |
# initialize empty project |
| 55 |
project <- renv_tests_scope() |
| 56 |
init() |
| 57 |
|
| 58 |
# make sure 'bread' isn't in the cache currently |
| 59 |
# install 'bread' into a user library path |
| 60 |
userlib <- renv_scope_tempdir("renv-library-") |
| 61 |
install("bread", library = userlib) |
| 62 |
|
| 63 |
# try to hydrate from that source |
| 64 |
hydrate(packages = "bread", sources = userlib) |
| 65 |
expect_true(renv_package_installed("bread")) |
| 66 |
|
| 67 |
}) |