tests/testthat/test-globals.R

test_that("set_golem_global function sets global variables correctly", {
  set_golem_global("test_var", "test_value")
  expect_equal(.golem_globals$test_var, "test_value")
  rm("test_var", envir = .golem_globals)

  set_golem_global("another_var", 123)
  expect_equal(.golem_globals$another_var, 123)
  rm("another_var", envir = .golem_globals)

})

Try the golem package in your browser

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

golem documentation built on Sept. 11, 2024, 7:54 p.m.