tests/testthat/setup.R

library(httptest2)
# Retrieve login credentials
username <- Sys.getenv("EP_USERNAME")
password <- Sys.getenv("EP_PASSWORD")
# Check if login credentials exist
is_active <- nzchar(username) && nzchar(password)
# If login credentials exist
if( is_active ){
    # Log into enviPath
    epLogin(username, password)
    # Clear httptest cache
    unlink(
        system.file("tests/testthat/httptest"),
        recursive = TRUE,
        force = TRUE
    )
}
# Redact httptest output
set_redactor(function (x) {
    # Remove address prefix
    x <- httptest2::gsub_response(x, "envipath.org/api/legacy/", "")
    # Reduce unique identifiers
    x <- httptest2::gsub_response(x, "/(?:[0-9a-z]+-){2,}[0-9a-z]+/", "_")
    return(x)
})
# Add parent directory to httptest paths
.mockPaths("../")

Try the enviPathR package in your browser

Any scripts or data that you put into this service are public.

enviPathR documentation built on Oct. 14, 2026, 5:07 p.m.