jumpingrivers / HIBPwned

R Package 📦 for using the HaveIBeenPwned.com API :scream:
http://jumpingrivers.github.io/HIBPwned/
Other
13 stars 4 forks source link

Add tests for the waiting and trying #9

Closed maelle closed 6 years ago

maelle commented 6 years ago

For that, use webmockr.

If I do that soon, I'll also need to replace httr with crul https://github.com/ropensci/webmockr

Or I could use the testing package which works with httr but I'm less enclined to do so. 🤔

stephlocke commented 6 years ago

Swapping out httr is a fairly large task - aside of making it a bit easier to test, are there other benefits?

maelle commented 6 years ago

No, well crul e.g. supports asynchronous requests but I think httr does now?

In any case, this wouldn't be something for the very next release I think.

stephlocke commented 6 years ago

okie dokie :)

maelle commented 6 years ago

First experiments with my I16 branch

library(crul)
library(testthat)

# make a stub
webmockr::enable()
stub <- webmockr::stub_request("get", "https://haveibeenpwned.com/api/breaches")
webmockr::to_return(stub, status = 404)
webmockr::stub_registry()
HIBPwned::breached_sites()
webmockr::disable()

head(HIBPwned::breached_sites())
maelle commented 6 years ago

will skip_on_cran() because these tests take a little while