tests/testthat/test-helper_functions.R

testthat::test_that("Setting and retrieving API key works", {
  # create a vector of API key string tests with different combinations
  # of numbers and letters.

  for(x in 10:50){
  # create random test string with length 10 - 50.
  test_string <- paste(sample(c(LETTERS, letters, "_", 1:100),
                              x),
                       collapse = "")

  # set the HealthSites API key
  set_hs_API_key(API_key = test_string)
  # run test expecting the get function to retrieve the initial key...
  testthat::expect_equal(
    get_hs_API_key(env_var_name = 'Healthsites_API_key'),
    test_string
  )

  }

})
dark-peak-analytics/who_decide_AP documentation built on May 25, 2022, 8:31 p.m.