tests/testthat/test-check_package_use.R

testthat::test_that("getPackageFunctions fails for non-existent package", {
  testthat::expect_error(
    getPackageFunctions("nonexistent_package"),
    "Unable to load"
  )
})

testthat::skip_if_offline("cran.rstudio.com")
options(repos = "https://cran.rstudio.com/")

testthat::test_that("getPackageFunctions returns character vector of functions in package", {
  functions <- getPackageFunctions("utils")

  testthat::expect_gt(length(functions), 0)
  testthat::expect_type(functions, "character")
})

testthat::test_that("getInternalPackageFunctions fails for non-existent package", {
  testthat::expect_error(
    getInternalPackageFunctions("nonexistent_package"),
    "Unable to load"
  )
})

testthat::test_that("getPackageFunctions returns character vector of functions in package", {
  functions <- getInternalPackageFunctions("utils")

  testthat::expect_gt(length(functions), 0)
  testthat::expect_type(functions, "character")
})
ashbaldry/depcheck documentation built on Jan. 1, 2022, 11:11 p.m.