tests/testthat/test-kvk_API.R

test_that("kvk_set_api_key sets environment variable correctly", {
  # Arrange
  test_key <- "test_api_key_12345"
  
  # Act
  expect_message(
    result <- kvk_set_api_key(test_key),
    "KVK_API_KEY has been set for this session"
  )
  
  # Assert
  expect_true(result)
  expect_invisible(kvk_set_api_key(test_key))  # Test invisibility separately
  expect_equal(Sys.getenv("KVK_API_KEY"), test_key)
})

Try the kvkapiR package in your browser

Any scripts or data that you put into this service are public.

kvkapiR documentation built on June 25, 2025, 5:11 p.m.