Closed joethorley closed 3 years ago
👋 @joethorley
Yep that's a good call. Seems like I really just need to check sooner if the user has internet then I don't need the hard stop. Any thoughts on how to write a test that mimics no internet?
@boshek - that's great. It's never anything I've done before.
This may be of interest
https://community.rstudio.com/t/unit-testing-for-non-working-internet-connection/31894
@joethorley are you able to check to see if the changes on the no-internet
branch work for your purposes?
remotes::install_github("ropensci/tidyhydat")
Still trying to assess whether I actually need a test for this.
That works for me - it doesn't issue a warning on load but in my opinion this is fine (even desirable) and then errors when attempting to download which is desirable with an informative error.
I'm not sure that a test is required.
> library(tidyhydat)
● Checking for a new version of HYDAT...
x Your version of HYDAT is out of date. Use download_hydat() to get the new version.
# switch off wifi
> library(tidyhydat)
> tidyhydat::download_hydat()
Downloading HYDAT will take ~10 minutes.
This will remove any older versions of HYDAT
Is that okay?
────────────────────────────────────────────────────────────────────────────────────────────
1: Yes
2: No
Selection: 1
● Downloading HYDAT.sqlite3 to ~/Library/Application Support/tidyhydat
Error in curl::curl_fetch_memory(url, handle = handle) :
Could not resolve host: collaboration.cmc.ec.gc.ca
Backtrace:
█
1. └─tidyhydat::download_hydat()
2. └─httr::GET(base_url)
3. └─httr:::request_perform(req, hu$handle$handle)
4. ├─[ httr:::request_fetch(...) ]
5. └─httr:::request_fetch.write_memory(req$output, req$url, handle)
6. └─curl::curl_fetch_memory(url, handle = handle)
Attempting to load tidyhydat with no internet causes an error - is it possible to replace the error with a warning so that scripts that use tidyhydat can be run without an internet connection?