| 1 |
|
| 2 |
test_that("properties can be read successfully", { |
| 3 |
|
| 4 |
data <- '# This is a comment.\nKey: Value' |
| 5 |
|
| 6 |
path <- renv_scope_tempfile("renv-properties-") |
| 7 |
writeLines(data, con = path) |
| 8 |
|
| 9 |
# trim whitespace by default |
| 10 |
props <- renv_properties_read(path = path) |
| 11 |
expect_identical(props, list(Key = "Value")) |
| 12 |
|
| 13 |
# without trimming whitespace |
| 14 |
props <- renv_properties_read(path = path, trim = FALSE) |
| 15 |
expect_identical(props, list(Key = " Value")) |
| 16 |
|
| 17 |
}) |
| 18 |
|
| 19 |
test_that("quoted properties are unquoted", { |
| 20 |
|
| 21 |
props <- renv_properties_read( |
| 22 |
path = "resources/properties.txt", |
| 23 |
delimiter = "=", |
| 24 |
dequote = TRUE, |
| 25 |
trim = TRUE |
| 26 |
) |
| 27 |
|
| 28 |
expected <- list( |
| 29 |
Key1 = "Value 1", |
| 30 |
Key2 = 'Value "2"', |
| 31 |
Key3 = "Value '3'" |
| 32 |
) |
| 33 |
|
| 34 |
expect_identical(props[names(expected)], expected) |
| 35 |
expect_equal(props$Key4, "This value spans multiple lines.") |
| 36 |
|
| 37 |
}) |