From 1d336ea74fd7d02a897fcf520b47a06b0b12cd36 Mon Sep 17 00:00:00 2001 From: Jan Marvin Garbuszus Date: Thu, 12 Sep 2024 11:33:39 +0200 Subject: [PATCH] [misc] cleanup in `wb_dims` code and add curl to gha (#1134) * [dims] simplify check * [tests] remove `testthat::skip_if_offline()` --- R/utils.R | 8 ++------ tests/testthat/helper.R | 15 +++++++++++++-- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/R/utils.R b/R/utils.R index b1b6b74c5..65b95786e 100644 --- a/R/utils.R +++ b/R/utils.R @@ -716,14 +716,10 @@ wb_dims <- function(..., select = NULL) { } if (!is.null(cols_arg)) { - # cols_arg could be name(s) in x or must indicate a positive integer is_lwr_one <- FALSE - if (!is.null(args$x)) { - if (!all(cols_arg %in% names(args$x))) - is_lwr_one <- min(col2int(cols_arg)) < 1L - } else { + # cols_arg could be name(s) in x or must indicate a positive integer + if (is.null(args$x) || (!is.null(args$x) && !all(cols_arg %in% names(args$x)))) is_lwr_one <- min(col2int(cols_arg)) < 1L - } if (is_lwr_one) stop("You must supply positive values to `cols`") diff --git a/tests/testthat/helper.R b/tests/testthat/helper.R index 231a4c73a..dec2404db 100644 --- a/tests/testthat/helper.R +++ b/tests/testthat/helper.R @@ -1044,9 +1044,20 @@ testsetup <- function() { } +dns_lookup <- function(host = "captive.apple.com") { + con <- try( + socketConnection(host, port = 80, open = "r+", timeout = 2), + silent = TRUE + ) + on.exit(close(con)) + + if (inherits(con, "try-error")) return(FALSE) + + TRUE +} + # 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() + testthat::skip_if_not(dns_lookup()) }