Debian Codegraph @

tests/testthat/test-plan.R

raw
1
2 test_that("plan() creates a lockfile without installing packages", {
3
4 project <- renv_tests_scope()
5 init()
6
7 renv_tests_dependencies("breakfast")
8 lockfile <- plan(project = project)
9
10 # packages should not be installed
11 expect_false(renv_package_installed("breakfast"))
12 expect_false(renv_package_installed("bread"))
13
14 # lockfile should exist and contain the full dependency tree
15 lockfile <- renv_lockfile_read(paths$lockfile(project = project))
16 records <- renv_lockfile_records(lockfile)
17
18 expect_true("breakfast" %in% names(records))
19 expect_true("oatmeal" %in% names(records))
20 expect_true("toast" %in% names(records))
21 expect_true("bread" %in% names(records))
22
23 # records should have dependency metadata
24 expect_identical(records$breakfast$Source, "Repository")
25 expect_identical(records$breakfast$Version, "1.0.0")
26 expect_true(!is.null(records$breakfast$Depends))
27
28 })
29
30 test_that("plan() with explicit packages resolves dependencies", {
31
32 project <- renv_tests_scope()
33 init()
34
35 lockfile <- plan(packages = "toast", project = project)
36 records <- renv_lockfile_records(lockfile)
37
38 expect_true("toast" %in% names(records))
39 expect_true("bread" %in% names(records))
40 expect_false("breakfast" %in% names(records))
41
42 })
43
44 test_that("plan() prints a dependency tree", {
45
46 project <- renv_tests_scope()
47 init()
48
49 renv_tests_dependencies("breakfast")
50 expect_snapshot(plan(project = project))
51
52 })