url <- "https://eu.httpbin.org/get?foo=123"
mk <- mock("mocked request")
dl <- function(x) curl::curl(x)
with_mock(`curl::curl` = mk, dl(url))
mock_call(mk)
mock_args(mk)
mock_n_called(mk)
mk <- mock({
url
})
with_mock(`curl::curl` = mk, dl(url))
my_return_val <- "mocked request"
mk <- mock(my_return_val)
with_mock(`curl::curl` = mk, dl(url))
Run the code above in your browser using DataLab