So, given that CRAN asks for a package that behaves gracefully when there is no internet, I'm pretty sure there is a base R way to test a function when there is no internet, without actually turning my WiFi down. Right? Even ChatGP doesn't know
#RStats question: Given that CRAN asks for functions using the internet to fail gracefully, how can I test the function behavior when there is no internet, other than just turning my Wi-Fi off?
5
1
4
I'm not sure how to implement that to work with any request ? I've found things that work with {curl} / {httr}, other that works for download.file(), but nothing that works everywhere :/
2
2
See dang::isConnected() which I initially wrote for another package (maybe RPushBullet? Maybe rfoas?). I basically wrap try() around a url() call and catch the error, if any. Only base #rstats github.com/eddelbuettel/dang…

Jan 12, 2023 Β· 6:12 PM UTC

1
1
1
Thanks! But what I actually try to achieve is simulate the function behavior if there is no internet. Context: CRAN wants to be sure that your func fail gracefully if the internet is down, so what I'm trying to achieve is a way to mimic this in my testing suite 1/2
1
So something in the spirit of: without_internet({ expect_fails_gracefully( my_function_that_downloads_a_file() ) }) But there seems to be no generalized way to do that unfortunately :/ 2/2
1