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
)
}
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.