Debian Codegraph @

tests/testthat/test-preflight.R

raw
1
2 test_that("snapshot preflight tests catch common issues", {
3
4 renv_tests_scope()
5
6 libpath <- renv_paths_library()
7 ensure_parent_directory(libpath)
8
9 # library is a file, not directory
10 file.create(libpath)
11 expect_error(snapshot(library = libpath))
12 unlink(libpath)
13
14 # project library does not exist
15 expect_error(snapshot(library = libpath))
16
17 # arbitrary library does not exist
18 expect_error(snapshot(library = tempfile()))
19
20 })
21
22 test_that("renv warns when snapshotting missing dependencies", {
23 skip_on_cran()
24
25 project <- renv_tests_scope("breakfast")
26 init()
27
28 remove("oatmeal")
29 expect_snapshot(snapshot(), error = TRUE)
30
31 lockfile <- renv_lockfile_load(project)
32 expect_true(!is.null(lockfile$Packages$oatmeal))
33
34 })