Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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.6.9005
Version: 0.3.6.9006
Authors@R: c(
person("Brendan", "Rocks", email = "[email protected]",
role = c("aut")),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# boxr 0.3.6 (development)

## fix bug in `box_save()`, setting default environment for evaluating dots (#255)

## Internal

* activate tests for `box_save()`, `box_load()` (#255)

* update documentation to reflect updates to rio package. (#242, @chainsawriot)

* update maintainer's email address. (#248)
Expand Down
2 changes: 1 addition & 1 deletion R/boxr_save_load.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ box_save <- function(..., dir_id = box_getwd(), file_name = ".RData",
# - see https://github.com/r-lib/usethis/issues/1217
on.exit(fs::file_delete(temp_file))

save(..., file = temp_file)
save(..., envir = parent.frame(), file = temp_file)

box_ul(dir_id, temp_file, description = description)
}
Expand Down
71 changes: 27 additions & 44 deletions tests/testthat/test_04_load_save.R
Original file line number Diff line number Diff line change
@@ -1,44 +1,27 @@
# Load/Save ---------------------------------------------------------------
# For some reason (probably related to environements), these run fine in the
# console/terminal, but testthat can't find the files when running them with
# devtools::test()
#
# Leaving not-run, for now
if (FALSE) {
context("Load/Save")

test_that("Saving R Object Remotely", {
skip_on_cran()
skip_if_no_token()

# Here's an R object
test_list <- list(data.frame(), 1:10, letters)
test_vars$test_list <- test_list
rda_name <- "test.RData"

# The upload should throw an error if it doesn't work
b <- box_save(test_list, envir = globalenv(), dir_id = 0, file_name = rda_name)

# Put the id in an environment variable for subsequent tests
test_vars$object_return <- b

# Did the file end up with the right name?
expect_equal(rda_name, b$entries[[1]]$name)
})

test_that("Loading remote R object", {
skip_on_cran()
skip_if_no_token()

rm("object")

# Can you load the remote file which stores the R object?
b <- box_load(test_vars$object_return$entries[[1]]$id)

# Did it return the right object name?
expect_equal("object", b)
# Is the R object the same after it's journey?
expect_equal(object, test_vars$object)
})

}
context("Load/Save")

test_that("object can be saved, retrieved, and deleted", {
skip_on_cran()
skip_if_no_token()

# Here's an R object
test_ref <- list(data.frame(), 1:10, letters)

test_list <- test_ref
rda_name <- "test.RData"

b_save <- box_save(test_list, dir_id = 0, file_name = rda_name)
expect_equal(rda_name, b_save$name)

rm("test_list")

# will load data into `test_list`
b_load <- box_load(b_save$id)
expect_identical(b_load, "test_list")
expect_equal(test_ref, test_list)

# clean up
box_delete_file(b_save$id)

})