Skip to content

Commit

Permalink
[misc] cleanup in wb_dims code and add curl to gha (#1134)
Browse files Browse the repository at this point in the history
* [dims] simplify check

* [tests] remove `testthat::skip_if_offline()`
  • Loading branch information
JanMarvin committed Sep 12, 2024
1 parent 5777f4b commit 1d336ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
8 changes: 2 additions & 6 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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`")
Expand Down
15 changes: 13 additions & 2 deletions tests/testthat/helper.R
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

0 comments on commit 1d336ea

Please sign in to comment.