tidytuesdayR icon indicating copy to clipboard operation
tidytuesdayR copied to clipboard

Suggestions for testing

Open hadley opened this issue 3 years ago • 0 comments

Using custom wrappers makes it harder for folks to drop in and understand what's happening in the tests, because you have to trace through multiple calls in order to figure out exactly what the local setup looks like. Instead, I think you should define a few helpers that you then copy and paste in to each test that use it (see https://mtlynch.io/good-developers-bad-tests/ for a good discussion of why repeating yourself in tests is actually good practice).

I'd suggesting starting with these two helpers:

skip_if_no_api <- function() {
  if (!get_connectivity()) {
    skip("Connection to Github.com not available")
  }
  
  if(rate_limit_check(quiet = TRUE) <= 20) {
    skip("Rate limit met")
  }
}

local_test_repo <- function(.env = parent.frame()) {
  withr::local_options("tidytuesdayR.tt_repo" = "thebioengineer/tt_ref")
}

hadley avatar Feb 10 '21 13:02 hadley