Skip to content

Commit

Permalink
use function to clear box directory
Browse files Browse the repository at this point in the history
  • Loading branch information
ijlyttle committed Jan 2, 2024
1 parent b578cf1 commit 7dee645
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
6 changes: 2 additions & 4 deletions R/boxr__internal_misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ create_test_dir <- function() {
return()
}


# A function to modify that directory structure
modify_test_dir <- function() {
# Delete a directory
Expand All @@ -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)

Check warning on line 317 in R/boxr__internal_misc.R

View check run for this annotation

Codecov / codecov/patch

R/boxr__internal_misc.R#L316-L317

Added lines #L316 - L317 were not covered by tests
}


Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_02_clear_out.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 1 addition & 2 deletions tests/testthat/test_99_tidy_up.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
Expand Down

0 comments on commit 7dee645

Please sign in to comment.