|
1 | | - |
2 | | -test_that("use_description_field() can address an existing field", { |
3 | | - pkg <- create_local_package() |
4 | | - orig <- tools::md5sum(proj_path("DESCRIPTION")) |
5 | | - |
6 | | - ## specify existing value of existing field --> should be no op |
7 | | - use_description_field( |
8 | | - name = "Version", |
9 | | - value = desc::desc_get("Version", pkg)[[1]], |
10 | | - base_path = pkg |
11 | | - ) |
12 | | - expect_identical(orig, tools::md5sum(proj_path("DESCRIPTION"))) |
13 | | - |
14 | | - expect_usethis_error( |
15 | | - use_description_field( |
16 | | - name = "Version", |
17 | | - value = "1.1.1", |
18 | | - base_path = pkg |
19 | | - ), |
20 | | - "has a different value" |
21 | | - ) |
22 | | - |
23 | | - ## overwrite existing field |
24 | | - use_description_field( |
25 | | - name = "Version", |
26 | | - value = "1.1.1", |
27 | | - base_path = pkg, |
28 | | - overwrite = TRUE |
29 | | - ) |
30 | | - expect_identical(c(Version = "1.1.1"), desc::desc_get("Version", pkg)) |
31 | | -}) |
32 | | - |
33 | | -test_that("use_description_field() can add new field", { |
34 | | - pkg <- create_local_package() |
35 | | - use_description_field(name = "foo", value = "bar", base_path = pkg) |
36 | | - expect_identical(c(foo = "bar"), desc::desc_get("foo", pkg)) |
37 | | -}) |
38 | | - |
39 | | -test_that("use_description_field() ignores whitespace", { |
40 | | - pkg <- create_local_package() |
41 | | - use_description_field(name = "foo", value = "\n bar") |
42 | | - use_description_field(name = "foo", value = "bar") |
43 | | - expect_identical(c(foo = "\n bar"), desc::desc_get("foo", pkg)) |
44 | | -}) |
45 | | - |
46 | 1 | test_that("valid_package_name() enforces valid package names", { |
47 | 2 | # Contain only ASCII letters, numbers, and '.' |
48 | 3 | # Have at least two characters |
|
0 commit comments