| 1 |
|
| 2 |
test_that("we can query actions for a sample project", { |
| 3 |
|
| 4 |
project <- renv_tests_scope("breakfast") |
| 5 |
renv_scope_options(renv.config.auto.snapshot = FALSE) |
| 6 |
init(bare = TRUE) |
| 7 |
install("breakfast") |
| 8 |
|
| 9 |
# project depends on 'breakfast' and 'breakfast' is installed |
| 10 |
# ergo, need to snapshot 4 packages |
| 11 |
acts <- actions("snapshot", project = getwd()) |
| 12 |
expect_equal(nrow(acts), 4L) |
| 13 |
expect_setequal(acts$Package, c("bread", "breakfast", "oatmeal", "toast")) |
| 14 |
expect_true(all(acts$Action == "install")) |
| 15 |
|
| 16 |
# note: empty for non-clean restore as we don't remove packages |
| 17 |
acts <- actions("restore", library = renv_paths_library(), project = getwd()) |
| 18 |
expect_equal(nrow(acts), 0L) |
| 19 |
|
| 20 |
# now non-empty |
| 21 |
acts <- actions("restore", library = renv_paths_library(), project = getwd(), clean = TRUE) |
| 22 |
expect_equal(nrow(acts), 4L) |
| 23 |
expect_setequal(acts$Package, c("bread", "breakfast", "oatmeal", "toast")) |
| 24 |
expect_true(all(acts$Action == "remove")) |
| 25 |
|
| 26 |
}) |
| 27 |
|
| 28 |
test_that("we can query actions when no lockfile has yet been generated", { |
| 29 |
renv_tests_scope("bread") |
| 30 |
init(bare = TRUE) |
| 31 |
install("bread") |
| 32 |
actions <- actions("snapshot") |
| 33 |
expect_equal(nrow(actions), 1L) |
| 34 |
}) |
| 35 |
|
| 36 |
test_that("bare usages of actions work as expected", { |
| 37 |
|
| 38 |
# set up project with 3 packages that need to be snapshotted |
| 39 |
renv_tests_scope("bread") |
| 40 |
renv_scope_options(renv.config.auto.snapshot = FALSE) |
| 41 |
|
| 42 |
init() |
| 43 |
install("breakfast") |
| 44 |
|
| 45 |
writeLines("library(breakfast)", con = "deps.R") |
| 46 |
acts <- actions("snapshot") |
| 47 |
|
| 48 |
expect_equal(nrow(acts), 3L) |
| 49 |
expect_setequal(acts$Package, c("breakfast", "oatmeal", "toast")) |
| 50 |
expect_true(all(acts$Action == "install")) |
| 51 |
|
| 52 |
}) |