tests/testthat/test-pkg_file.R

test_that("pkg_file returns correct path to DESCRIPTION", {
    expected <- system.file("DESCRIPTION", package = "metabodecon")
    actual <- pkg_file("DESCRIPTION")
    expect_equal(actual, expected)
})

test_that("pkg_file returns correct path to file in inst folder", {
    expected <- system.file("WORDLIST", package = "metabodecon")
    actual <- pkg_file("WORDLIST")
    expect_equal(actual, expected)
})

test_that("pkg_file returns correct path to package root directory", {
    expected <- system.file(package = "metabodecon")
    actual <- pkg_file()
    expect_equal(actual, expected)
})

test_that("pkg_file raises error if file does not exist and mustWork is TRUE", {
    expect_error(pkg_file("nonexistent_file.txt", mustWork = TRUE))
})

Try the metabodecon package in your browser

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

metabodecon documentation built on Nov. 5, 2025, 7:12 p.m.