Closed pbulsink closed 4 months ago
This works on my machine:
library(httr2)
#> Warning: package 'httr2' was built under R version 4.3.1
library(testthat)
#>
#> Attaching package: 'testthat'
#> The following objects are masked from 'package:httr2':
#>
#> local_mock, with_mock
library(httptest2)
#> Warning: package 'httptest2' was built under R version 4.3.1
without_internet({
expect_error(
request("http://httpbin.org/get") %>% req_perform(),
"GET http://httpbin.org/get"
)})
Created on 2024-03-05 with reprex v2.1.0
The error may be coming from this line, which is a compatibility layer to adapt to a change in function names in httr2 1.0: https://github.com/nealrichardson/httptest2/blob/cff21ee6e0a38e4b43826493d4afc4862d37a25e/R/expect-request-header.R#L90
I'm not sure how you could end up in the wrong branch of that code. Are you on the latest version of httr2 and httptest2?
Looks like I had an old dev version of httr2 somehow, once I updated it was no problem. Thanks for looking at this!
I get a failure when running the example code for without_internet on any request without a mocked response.
The ideal situation is that this function could be used as a simple test environment for handling loss of internet connection, without having to build in code escape hatches to fake no internet. Having to mock responses instead of just faceplanting into a no-connection scenario is more overhead than needed.