From 7dee64532e216141a22e93f1d80e8d9d11923c12 Mon Sep 17 00:00:00 2001 From: Ian Lyttle Date: Tue, 2 Jan 2024 17:58:39 -0600 Subject: [PATCH] use function to clear box directory --- R/boxr__internal_misc.R | 6 ++---- tests/testthat/test_02_clear_out.R | 2 +- tests/testthat/test_99_tidy_up.R | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/R/boxr__internal_misc.R b/R/boxr__internal_misc.R index c06e1e6c..3f81e37a 100644 --- a/R/boxr__internal_misc.R +++ b/R/boxr__internal_misc.R @@ -294,7 +294,6 @@ create_test_dir <- function() { return() } - # A function to modify that directory structure modify_test_dir <- function() { # Delete a directory @@ -314,9 +313,8 @@ modify_test_dir <- function() { # A function to clear out a box.com directory clear_box_dir <- function(dir_id) { - dir.create("delete_me", showWarnings = FALSE) - box_push(dir_id, "delete_me", delete = TRUE) - unlink("delete_me", recursive = TRUE, force = TRUE) + tmp_dir <- withr::local_tempdir() + box_push(dir_id, tmp_dir, delete = TRUE) } diff --git a/tests/testthat/test_02_clear_out.R b/tests/testthat/test_02_clear_out.R index 7b389ff7..42e7c0a1 100644 --- a/tests/testthat/test_02_clear_out.R +++ b/tests/testthat/test_02_clear_out.R @@ -20,7 +20,7 @@ test_that("Clear out the remote directory", { options(boxr.verbose = FALSE) # Tell boxr to sync the remote home directory with an empty local one # (i.e. delete everything) - b <- box_push(0, fs::path_temp("test_dir/dir_12/dir_121/dir_1211"), delete = TRUE) + boxr:::clear_box_dir(0) expect_length(box_ls(0), 0) diff --git a/tests/testthat/test_99_tidy_up.R b/tests/testthat/test_99_tidy_up.R index 620ebdb3..7b0d6d7f 100644 --- a/tests/testthat/test_99_tidy_up.R +++ b/tests/testthat/test_99_tidy_up.R @@ -5,8 +5,7 @@ test_that("Box directory is emptied", { boxr:::skip_on_travis() skip_if_no_token() - # push empty local dir to top level on Box - b <- box_push(0, fs::path_temp("test_dir/dir_12/dir_121/dir_1211"), delete = TRUE) + boxr:::clear_box_dir(0) expect_equal(nrow(as.data.frame(box_ls(0))), 0) })