Nothing
# setup script for galah test suite
# set up quiet versions of repeated functions
quiet_collapse <- function(x, ...){
collapse_fun <- purrr::quietly(dplyr::collapse)
collapse_fun(x, ...) |>
purrr::pluck("result")
}
quiet_compute <- function(x){
compute_fun <- purrr::quietly(dplyr::compute)
compute_fun(x) |>
purrr::pluck("result")
}
quiet_collect <- function(x, ...){
purrr_collect <- purrr::quietly(dplyr::collect)
purrr_collect(x, ...) |>
purrr::pluck("result")
}
# set up bespoke skip_ functions to enforce preferred test behaviour
# check status and cache *before* running tests
if(httr2::is_online()){
Sys.setenv("NOT_ONLINE" = "")
}else{
Sys.setenv("NOT_ONLINE" = "true")
}
# note this differs from skip_if_offline() ONLY by caching the result
# this reduces pings to captive.apple.com
# encode this into a rule to pass to `skip`
is_online_cached <- function(){
x <- Sys.getenv("NOT_ONLINE")
if(x == ""){
TRUE
}else{ # including when == "true"
FALSE
}
}
# new function to enact desirable testing behaviour
skip_galah <- function(){
skip_on_cran()
skip_if(!is_online_cached(), "offline")
skip_on_ci()
}
# new function to silently skip failed tests
skip_unavailable <- function(x, other_classes = c()){
# capture with `try()`
result <- x |>
try(silent = TRUE)
# skip if `try()` fails
default_class <- "try-error"
if(inherits(result, c(default_class, other_classes))){
testthat::skip(message = "API not available")
}else{
return(result)
}
}
# simple function to show we expect a tibble
expect_tibble <- function(x){
expect_s3_class(x, c("tbl_df", "tbl", "data.frame"))
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.