diff --git a/tests/testthat/helper.R b/tests/testthat/helper.R index 65635eb24..231a4c73a 100644 --- a/tests/testthat/helper.R +++ b/tests/testthat/helper.R @@ -1043,3 +1043,10 @@ testsetup <- function() { } } + +# testthat::skip_if_offline requires curl, but fails if curl is not available +skip_online_checks <- function() { + testthat::skip_on_cran() + testthat::skip_if_not_installed("curl") + testthat::skip_if_offline() +} diff --git a/tests/testthat/test-read_sources.R b/tests/testthat/test-read_sources.R index 609036ae6..6417d827e 100644 --- a/tests/testthat/test-read_sources.R +++ b/tests/testthat/test-read_sources.R @@ -1,6 +1,6 @@ test_that("read_xlsx from different sources", { - skip_if_offline() + skip_online_checks() ## URL xlsxFile <- "https://github.com/JanMarvin/openxlsx2/raw/main/inst/extdata/oxlsx2_sheet.xlsx" @@ -26,7 +26,7 @@ test_that("read_xlsx from different sources", { test_that("wb_load from different sources", { - skip_if_offline() + skip_online_checks() ## URL xlsxFile <- "https://github.com/JanMarvin/openxlsx2/raw/main/inst/extdata/oxlsx2_sheet.xlsx" @@ -194,7 +194,7 @@ test_that("reading charts", { test_that("load file with xml namespace", { - skip_if_offline() + skip_online_checks() fl <- "https://github.com/ycphs/openxlsx/files/8480120/2022-04-12-11-42-36-DP_Melanges1.xlsx" @@ -305,7 +305,7 @@ test_that("reading of formControl works", { test_that("reading xml escapes works", { - skip_if_offline() + skip_online_checks() fl <- "https://github.com/ycphs/openxlsx/files/10032200/sample_data.xlsx" wb <- wb_load(fl) diff --git a/tests/testthat/test-read_xlsb.R b/tests/testthat/test-read_xlsb.R index 67d48bd41..9cd68a738 100644 --- a/tests/testthat/test-read_xlsb.R +++ b/tests/testthat/test-read_xlsb.R @@ -1,6 +1,6 @@ test_that("reading xlsb works", { - skip_if_offline() + skip_online_checks() xlsxFile <- testfile_path("openxlsx2_example.xlsb") @@ -21,7 +21,7 @@ test_that("reading xlsb works", { test_that("reading complex xlsb works", { - skip_if_offline() + skip_online_checks() xlsxFile <- testfile_path("hyperlink.xlsb") @@ -65,7 +65,7 @@ test_that("reading complex xlsb works", { test_that("worksheets with real world formulas", { - skip_if_offline() + skip_online_checks() xlsxFile <- testfile_path("nhs-core-standards-for-eprr-v6.1.xlsb")