tests/testthat/test-read_glob.R

test_that("testing read_glob()", {
  # A single file
  test_script("success.R") |>
    read_glob() |>
    expect_equal(test_script("success.R"))

  # All R files in a directory
  test_script("") |>
    file.path("*.R") |>
    read_glob() |>
    expect_match("\\.R$") |>
    length() |>
    expect_gt(1)

  # Error when file does not exist
  test_script("") |>
    file.path("fake_program.R") |>
    read_glob() |>
    expect_message()
})

Try the whirl package in your browser

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

whirl documentation built on April 16, 2025, 1:11 a.m.