Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix box_delete_folder() #200

Merged
merged 10 commits into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: boxr
Type: Package
Title: Interface for the 'Box.com API'
Version: 0.3.5.9014
Version: 0.3.5.9015
Authors@R: c(
person("Brendan", "Rocks", email = "foss@brendanrocks.com",
role = c("aut")),
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

## Bug Fixes

* `box_file_delete()` and `box_folder_delete()` each now return `invisible(NULL)`. (#197)

* `box_auth_service()` more resilient to bad-request failures. (#166)

* `box_auth()` longer throws error if {usethis} not installed. (#168, @malcombarret)
Expand Down
2 changes: 1 addition & 1 deletion R/boxr_auth.R
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ box_auth_on_attach <- function(auth_on_attach = FALSE) {
#' @param token_text `character`, JSON text. If this is provided,
#' `token_file` is ignored.
#'
#' @return Invisible `NULL`, called for side-effects.
#' @return `r string_side_effects()`
#'
#' @seealso \describe{
#' \item{[box_auth()]}{for authenticating to interactive-apps.}
Expand Down
10 changes: 6 additions & 4 deletions R/boxr_delete_restore.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
#'
#' @inheritParams box_browse
#' @return \describe{
#' \item{`box_delete_file()`}{Object with S3 class [`boxr_file_reference`][boxr_S3_classes].}
#' \item{`box_delete_file()`}{Invisible `NULL`, called for side effects.}
#' \item{`box_restore_file()`}{Object with S3 class [`boxr_file_reference`][boxr_S3_classes].}
#' \item{`box_delete_folder()`}{Object with S3 class [`boxr_folder_reference`][boxr_S3_classes].}
#' \item{`box_delete_folder()`}{Invisible `NULL`, called for side effects.}
#' \item{`box_restore_folder()`}{Object with S3 class [`boxr_folder_reference`][boxr_S3_classes].}
#' }
#'
#' @export
box_delete_file <- function(file_id) {
invisible(boxDeleteFile(file_id))
boxDeleteFile(file_id)
invisible(NULL)
}

#' @rdname box_delete_file
Expand Down Expand Up @@ -53,7 +54,8 @@ box_restore_file <- function(file_id) {
#' @rdname box_delete_file
#' @export
box_delete_folder <- function(dir_id) {
add_folder_ref_class(httr::content(boxDeleteFolder(dir_id)))
boxDeleteFolder(dir_id)
invisible(NULL)
}


Expand Down
2 changes: 1 addition & 1 deletion man/box_auth_service.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/box_delete_file.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions tests/testthat/test_15_delete.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
test_that("box_folder_delete() works", {

skip_if_no_token()

name_dir <- "test-folder-delete"

folder <- box_dir_create(name_dir, parent_dir_id = 0)

# check that box_delete_folder returns invisible(NULL)
expect_invisible(
expect_null(
box_delete_folder(folder$id)
)
)

# check that name_dir is not in box directory
names <- box_ls(0) %>% as.data.frame() %>% `[[`("name")
expect_false(name_dir %in% names)

})


test_that("box_file_delete() works", {

skip_if_no_token()

name_file <- "test-file-delete.rds"

file_upload <- box_save_rds("test", file_name = name_file, dir_id = 0)

# check that box_delete_file returns invisible(NULL)
expect_invisible(
expect_null(
box_delete_file(file_upload$id)
)
)

# check that name_file is not in box directory
names <- box_ls(0) %>% as.data.frame() %>% `[[`("name")
expect_false(name_file %in% names)

})