Skip to content

Commit

Permalink
merge main, fix NEWS
Browse files Browse the repository at this point in the history
Merge commit '79423363265fabc18ba971f1e969fff11dfeb247'

#Conflicts:
#	NEWS.md
  • Loading branch information
ijlyttle committed Feb 3, 2024
2 parents 209412e + 7942336 commit d2615f3
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 46 deletions.
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.9006
Version: 0.3.6.9007
Authors@R: c(
person("Brendan", "Rocks", email = "[email protected]",
role = c("aut")),
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# boxr 0.3.6 (development)

## Fixes

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

## Internal

* refactor to use withr functions to handle temp files. (#183)

* 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 @@ -33,7 +33,7 @@ box_save <- function(..., dir_id = box_getwd(), file_name = ".RData",

temp_file <- withr::local_tempfile(pattern = file_name)

Check warning on line 34 in R/boxr_save_load.R

View check run for this annotation

Codecov / codecov/patch

R/boxr_save_load.R#L34

Added line #L34 was not covered by tests

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)

})

0 comments on commit d2615f3

Please sign in to comment.