tests/testthat/test-tar_git_ok.R

targets::tar_test("tar_git_ok()", {
  skip_os_git()
  expect_true(tar_git_ok())
  expect_message(tar_git_ok(verbose = TRUE))
  expect_silent(tar_git_ok(verbose = FALSE))
})

targets::tar_test("tar_git_ok()", {
  skip_os_git()
  old <- Sys.getenv("TAR_GIT", unset = Sys.which("git"))
  on.exit(Sys.setenv(TAR_GIT = old))
  tmp <- tempfile()
  file.create(tmp)
  Sys.setenv(TAR_GIT = tmp)
  expect_false(tar_git_ok())
  expect_message(tar_git_ok(verbose = TRUE))
  expect_silent(tar_git_ok(verbose = FALSE))
})

Try the gittargets package in your browser

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

gittargets documentation built on May 29, 2024, 4:25 a.m.