Skip to content

Commit

Permalink
[wb_load] add path to object on. closes #741 (#742)
Browse files Browse the repository at this point in the history
* [wb_load] add path to object on

* fix test
  • Loading branch information
JanMarvin authored Aug 17, 2023
1 parent a23bcd8 commit 1f43b55
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions R/wb_load.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ wb_load <- function(
xmlFiles <- xmlFiles[ordr]

wb <- wb_workbook()
wb$path <- file

grep_xml <- function(pattern, perl = TRUE, value = TRUE, ...) {
# targets xmlFiles; has presents
Expand Down
14 changes: 14 additions & 0 deletions tests/testthat/test-read_from_created_wb.R
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,17 @@ test_that("reading with pre defined types works", {
expect_equal(got, dat, ignore_attr = TRUE)

})

test_that("wb_load contains path", {

tmp <- temp_xlsx()
wb_workbook()$add_worksheet()$add_worksheet()$save(tmp)
wb_load(tmp)$remove_worksheet()$save()

wb <- wb_load(tmp)

exp <- c(`Sheet 1` = "Sheet 1")
got <- wb$get_sheet_names()
expect_equal(exp, got)

})
2 changes: 1 addition & 1 deletion tests/testthat/test-read_sources.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ test_that("wb_load from different sources", {
wb_file <- wb_load(xlsxFile)

# Loading from URL vs local not equal
expect_equal_workbooks(wb_url, wb_file, ignore_fields = "datetimeCreated")
expect_equal_workbooks(wb_url, wb_file, ignore_fields = c("datetimeCreated", "path"))
})


Expand Down

0 comments on commit 1f43b55

Please sign in to comment.