Skip to content

Commit

Permalink
Use cli_bullets and a couple of cli_rules
Browse files Browse the repository at this point in the history
  • Loading branch information
weshinsley committed Jul 8, 2024
1 parent d599e82 commit c1ff746
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
15 changes: 7 additions & 8 deletions R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -476,13 +476,12 @@ empty_time <- function() {
maybe_unlink <- function(x, recursive = FALSE, dry_run = FALSE) {
if (!dry_run) {
unlink(x, recursive)
return()
}
recurse <- if (recursive) " recursively."
cli::cli_alert_info("Dry_run - would have deleted:")
ul <- cli::cli_ul()
for (file in x) {
cli::cli_li("{file}{recurse}")
} else {
recurse <- if (recursive) " recursively."
files <- paste0(x, recurse)
names(files) <- rep("*", length(files))
cli::cli_rule(right = "Dry run - files were not deleted {cli::symbol$arrow_down}")
cli::cli_bullets(files)
cli::cli_rule(right = "Dry run - files were not deleted {cli::symbol$arrow_up}")
}
cli::cli_end(ul)
}
10 changes: 5 additions & 5 deletions tests/testthat/test-purge.R
Original file line number Diff line number Diff line change
Expand Up @@ -296,15 +296,15 @@ test_that("can do a dry run purge", {
res <- evaluate_promise(hipercow_purge(in_bundle = "*", root = path,
dry_run = TRUE))
expect_equal(res$result, b$ids)
expect_length(res$messages, 10)
expect_length(res$messages, 12)
expect_match(res$messages[[1]], "Purging 5 tasks")
expect_match(res$messages[[2]], "Dry_run")
expect_match(res$messages[[8]], "Deleting 1 task bundle")
expect_match(res$messages[[9]], "Dry_run")
expect_match(res$messages[[2]], "Dry run")
expect_match(res$messages[[9]], "Deleting 1 task bundle")
expect_match(res$messages[[10]], "Dry run")

files <- gsub("[^a-zA-Z0-9:_/\\]", "",
gsub(" recursively.", "",
res$message[c(3:7, 10)]))
res$message[c(3:7, 11)]))

expect_true(all(file.exists(files)))
suppressMessages(hipercow_purge(in_bundle = "*", root = path))
Expand Down

0 comments on commit c1ff746

Please sign in to comment.