Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
richfitz committed Sep 29, 2023
1 parent 20ed1d2 commit 6f7b60b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions R/outpack_config.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,15 @@ config_set_path_archive <- function(value, root) {
path_archive_old <- file.path(root$path, config$core$path_archive)
if (fs::dir_exists(path_archive_old)) {
path_archive_new <- file.path(root$path, value)
assert_relative_path(value, name = "path_archive", workdir = root$path)
assert_relative_path(value, name = "'path_archive'", workdir = root$path)
assert_directory_does_not_exist(path_archive_new)
fs::dir_copy(path_archive_old, path_archive_new)
fs::dir_delete(path_archive_old)
}
config$core$path_archive <- value
} else {
path_archive <- file.path(root$path, value)
assert_relative_path(value, name = "path_archive", workdir = root$path)
assert_relative_path(value, name = "'path_archive'", workdir = root$path)
assert_directory_does_not_exist(path_archive)
tryCatch({
fs::dir_create(path_archive)
Expand Down
2 changes: 1 addition & 1 deletion R/util_assert.R
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ assert_relative_path <- function(files, name, workdir, call = NULL) {
n <- cli::qty(sum(err))
## TODO: try and relativise - use path_has_parent and path_rel
cli::cli_abort(
c("{name}{n}{?s} must be relative path{?s}",
c("{name}{n}{?s} must be {?a/} relative path{?s}",
set_names(files[err], "x"),
i = "Path was relative to directory '{workdir}'"),
call = call)
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-outpack-config.R
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ test_that("Archive is not added if file store is corrupt", {
test_that("Validates path_archive", {
root <- create_temporary_root(path_archive = NULL, use_file_store = TRUE)
expect_error(orderly_config_set(core.path_archive = "/archive", root = root),
"'path_archive' must be relative path")
"'path_archive' must be a relative path")
expect_null(root$config$core$path_archive)

dir.create(file.path(root$path, "archive"))
Expand All @@ -281,7 +281,7 @@ test_that("Validates path_archive", {

orderly_config_set(core.path_archive = "new-archive", root = root)
expect_error(orderly_config_set(core.path_archive = "/archive", root = root),
"'path_archive' must be relative path")
"'path_archive' must be a relative path")
expect_error(orderly_config_set(core.path_archive = "archive", root = root),
"Directory already exists")
expect_equal(root$config$core$path_archive, "new-archive")
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-util-assert.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ test_that("assert_is_directory", {
test_that("assert_relative_path", {
workdir <- getwd()
expect_error(assert_relative_path(getwd(), "File", workdir),
"File must be relative path",
"File must be a relative path",
fixed = TRUE)
expect_silent(assert_relative_path("relpath", "File", workdir))
expect_silent(assert_relative_path("a/b/c", "File", workdir))
Expand Down

0 comments on commit 6f7b60b

Please sign in to comment.