From 42500a12d369baed87393e7b2951047b42758824 Mon Sep 17 00:00:00 2001 From: Jan Marvin Garbuszus Date: Thu, 17 Aug 2023 20:11:13 +0200 Subject: [PATCH 1/2] [wb_load] add path to object on --- R/wb_load.R | 1 + tests/testthat/test-read_from_created_wb.R | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/R/wb_load.R b/R/wb_load.R index 377f28514..d33887961 100644 --- a/R/wb_load.R +++ b/R/wb_load.R @@ -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 diff --git a/tests/testthat/test-read_from_created_wb.R b/tests/testthat/test-read_from_created_wb.R index 35a8c7e33..085303956 100644 --- a/tests/testthat/test-read_from_created_wb.R +++ b/tests/testthat/test-read_from_created_wb.R @@ -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) + +}) From be367ffa696b0cd063f00a1c055c558d4fa746ea Mon Sep 17 00:00:00 2001 From: Jan Marvin Garbuszus Date: Thu, 17 Aug 2023 20:30:58 +0200 Subject: [PATCH 2/2] fix test --- tests/testthat/test-read_sources.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-read_sources.R b/tests/testthat/test-read_sources.R index 05dd8db42..d136bc918 100644 --- a/tests/testthat/test-read_sources.R +++ b/tests/testthat/test-read_sources.R @@ -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")) })