diff --git a/R/utils_files.R b/R/utils_files.R index 9e4f10ee..bb46408f 100644 --- a/R/utils_files.R +++ b/R/utils_files.R @@ -32,6 +32,7 @@ file_info_runtime <- function(x) { if_any( !is.null(file_info) && !is.null(file_info_exist) && + (length(x) > 0L) && all(counter_exist_names(file_info_exist, x)), .subset2(file_info, x), # nolint file_info(x) diff --git a/tests/testthat/test-utils_callr.R b/tests/testthat/test-utils_callr.R index 1e53f6c5..c0fd6534 100644 --- a/tests/testthat/test-utils_callr.R +++ b/tests/testthat/test-utils_callr.R @@ -83,10 +83,22 @@ tar_test("file path caches are correct", { ) info <- tar_read(file_info) expect_true(is.list(info)) - expect_true(all(c("size", "mtime_numeric") %in% names(info))) - names <- sort(path_objects(path_store_default(), c("x", "y"))) - for (field in c("size", "mtime_numeric")) { - expect_equal(sort(names(info[[field]])), names) - expect_false(anyNA(info[[field]])) + expect_equal( + sort(names(info)), + sort(file.path(path_objects_dir(path_store_default()), c("x", "y"))) + ) + for (item in info) { + expect_equal( + sort(names(item)), + sort(c("size", "mtime_numeric", "trust_timestamps")) + ) + for (field in c("size", "mtime_numeric")) { + expect_false(anyNA(item[[field]])) + expect_true(is.numeric(item[[field]])) + expect_equal(length(item[[field]]), 1L) + } + expect_true( + isTRUE(item$trust_timestamps) || isFALSE(item$trust_timestamps) + ) } }) diff --git a/tests/testthat/test-utils_files.R b/tests/testthat/test-utils_files.R index 2c0e9ba9..435361b6 100644 --- a/tests/testthat/test-utils_files.R +++ b/tests/testthat/test-utils_files.R @@ -143,22 +143,6 @@ tar_test("file_info_runtime() with no files registered", { expect_true(is.data.frame(out)) }) -tar_test("file_info_runtime_select()", { - files <- unlist(replicate(6, tempfile())) - file.create(files) - on.exit(unlink(files)) - info <- list( - mtime_numeric = seq_along(files), - size = file.size(files) + seq_along(files) - ) - names(info$mtime_numeric) <- files - names(info$size) <- files - index <- c(2L, 3L, 5L) - out <- file_info_runtime_select(info, files[index]) - expect_equal(out$mtime_numeric, info$mtime_numeric[index]) - expect_equal(out$size, info$size[index]) -}) - tar_test("file_move() on files", { file.create("x") dir.create("z")