tests/testthat/test-path_package.R

describe("path_package", {
  it("errors if the package does not exist", {
    cnd <- tryCatch(path_package("arst"), error = function(e) e)
    expect_s3_class(cnd, "EEXIST")
    expect_match(conditionMessage(cnd), "Can't find package")
  })
  it("errors if the package location is not found", {
    cnd <- tryCatch(path_package("base", "foo"), error = function(e) e)
    expect_s3_class(cnd, "EEXIST")
    expect_match(conditionMessage(cnd), "do(es)? not exist")
  })
  it("works on installed files", {
    expect_error_free(p <- path_package("base", "INDEX"))
    expect_s3_class(p, "fs_path")
  })
})

Try the fs package in your browser

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

fs documentation built on Oct. 30, 2024, 9:06 a.m.