tests/testthat/test-i_am.R

local_project()

test_that("i_am() sets the project root", {
  # To reset later on
  local_here(here())
  withr::local_dir(here())

  expect_message(
    here::i_am("prepare/penguins.R", uuid = "115147ca-fedd-42ca-8650-2cb3dad0aebc"),
    "starts at"
  )

  dr <- format_dr_here(show_reason = TRUE)
  dr <- gsub(here(), "<project root>", dr, fixed = TRUE)
  expect_snapshot(writeLines(dr))
})

test_that("i_am() fails with useful message", {
  # To reset later on
  local_here(here())
  withr::local_dir(tempdir())

  expect_snapshot_with_error(
    here::i_am("prepare/penguins.R", uuid = "115147ca-fedd-42ca-8650-2cb3dad0aebc")
  )
})

Try the here package in your browser

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

here documentation built on Jan. 13, 2021, 12:17 p.m.