nealrichardson / httptest

A Test Environment for HTTP Requests in R
https://enpiar.com/r/httptest/
Other
79 stars 10 forks source link

expect_GET() and others don't detect httr calls #67

Closed ErdaradunGaztea closed 2 years ago

ErdaradunGaztea commented 2 years ago

Problem

I noticed that the whole expect_verb() family doesn't detect any calls made through httr; including these used as examples to docs.

# An example of a call that throws no error even though it should
httptest::expect_no_request(httr::GET("http://example.com"))

However, httr is detected in at least some functions:

# This code throws error as expected
httptest::without_internet(httr::GET("http://httpbin.org/get"))

Session info

R version 4.1.2 (2021-11-01) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale: [1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] httr_1.4.2 httptest_4.1.0 woodendesc_0.0.0.9000 usethis_2.1.5
[5] testthat_3.1.2

loaded via a namespace (and not attached): [1] Rcpp_1.0.8 pillar_1.7.0 compiler_4.1.2 base64enc_0.1-3 tools_4.1.2 pkgload_1.2.4
[7] digest_0.6.29 jsonlite_1.8.0 lifecycle_1.0.1 tibble_3.1.6 pkgconfig_2.0.3 rlang_1.0.1
[13] cli_3.2.0 rstudioapi_0.13 yaml_2.3.5 curl_4.3.2 crul_1.2.0 withr_2.5.0
[19] desc_1.4.1 fauxpas_0.5.0 fs_1.5.2 vctrs_0.3.8 triebeard_0.3.0 rprojroot_2.0.2 [25] glue_1.6.2 httpcode_0.3.0 R6_2.5.1 fansi_1.0.2 purrr_0.3.4 vcr_1.0.2
[31] webmockr_0.8.0 magrittr_2.0.2 whisker_0.4 urltools_1.7.3 ellipsis_0.3.2 utf8_1.2.2
[37] crayon_1.5.1 brio_1.1.3

nealrichardson commented 2 years ago

Yeah, the expect_VERB functions only work inside the mock contexts

ErdaradunGaztea commented 2 years ago

Ahh, thanks, somehow I missed that! I'm closing the issue then.