| 1 |
|
| 2 |
test_that("we can check out packages from our local repository", { |
| 3 |
|
| 4 |
# enter test scope |
| 5 |
project <- renv_tests_scope() |
| 6 |
init() |
| 7 |
|
| 8 |
# check out a package + its dependencies; this invocation is |
| 9 |
# similar in spirit to a plain `install()` call |
| 10 |
renv_tests_dependencies("breakfast") |
| 11 |
checkout(packages = "breakfast") |
| 12 |
|
| 13 |
# check that they were installed |
| 14 |
expect_true(renv_package_installed("breakfast")) |
| 15 |
expect_true(renv_package_installed("bread")) |
| 16 |
|
| 17 |
}) |
| 18 |
|
| 19 |
test_that("checkout with actions = 'snapshot' creates a lockfile without installing", { |
| 20 |
|
| 21 |
project <- renv_tests_scope() |
| 22 |
init() |
| 23 |
|
| 24 |
# checkout with snapshot action only -- no packages should be installed |
| 25 |
checkout(packages = "breakfast", actions = "snapshot") |
| 26 |
|
| 27 |
# packages should not be installed |
| 28 |
expect_false(renv_package_installed("breakfast")) |
| 29 |
expect_false(renv_package_installed("bread")) |
| 30 |
|
| 31 |
# lockfile should exist and contain the full dependency tree |
| 32 |
lockfile <- renv_lockfile_read(paths$lockfile(project = project)) |
| 33 |
records <- renv_lockfile_records(lockfile) |
| 34 |
|
| 35 |
expect_true("breakfast" %in% names(records)) |
| 36 |
expect_true("oatmeal" %in% names(records)) |
| 37 |
expect_true("toast" %in% names(records)) |
| 38 |
expect_true("bread" %in% names(records)) |
| 39 |
|
| 40 |
# records should have dependency metadata |
| 41 |
expect_identical(records$breakfast$Source, "Repository") |
| 42 |
expect_identical(records$breakfast$Version, "1.0.0") |
| 43 |
expect_true(!is.null(records$breakfast$Depends)) |
| 44 |
|
| 45 |
}) |
| 46 |
|
| 47 |
test_that("activate.R has no unreplaced placeholders after checkout", { |
| 48 |
|
| 49 |
project <- renv_tests_scope("breakfast") |
| 50 |
init() |
| 51 |
|
| 52 |
checkout(packages = "breakfast", actions = c("snapshot", "restore")) |
| 53 |
|
| 54 |
activate <- renv_paths_activate(project = project) |
| 55 |
contents <- readLines(activate) |
| 56 |
placeholders <- grep("\\.\\.[a-zA-Z0-9]+\\.\\.", contents, value = TRUE) |
| 57 |
expect_length(placeholders, 0) |
| 58 |
|
| 59 |
}) |
| 60 |
|
| 61 |
test_that("renv_infrastructure_write_activate is skipped during checkout", { |
| 62 |
|
| 63 |
project <- renv_tests_scope("breakfast") |
| 64 |
init() |
| 65 |
|
| 66 |
renv_scope_binding(the, "activate_deferred", TRUE) |
| 67 |
result <- renv_infrastructure_write_activate(project = project) |
| 68 |
expect_false(result) |
| 69 |
|
| 70 |
}) |
| 71 |
|
| 72 |
test_that("we can check out packages from the package manager instance", { |
| 73 |
|
| 74 |
skip_on_cran() |
| 75 |
|
| 76 |
renv_tests_scope() |
| 77 |
init() |
| 78 |
|
| 79 |
# ensure we reset repos on exit |
| 80 |
renv_scope_options(repos = getOption("repos")) |
| 81 |
|
| 82 |
# install renv from an old snapshot (pure R, no compiled code) |
| 83 |
. <- checkout(date = "2023-01-02", packages = "renv") |
| 84 |
|
| 85 |
}) |