tests/testthat/test-is_installed.R

test_that("load equals true", {

  expect_true(is_installed("utils", load = TRUE))

  expect_equal(
    is_installed(c("utils", "testthat", "thispackagedoesnotexist"), load = TRUE),
    c("utils" = TRUE, "testthat" = TRUE, "thispackagedoesnotexist" = FALSE)
  )

})


test_that("load equals false (default)", {

  expect_true(is_installed("utils"))

  expect_equal(
    is_installed(c("utils", "testthat", "thispackagedoesnotexist")),
    c("utils" = TRUE, "testthat" = TRUE, "thispackagedoesnotexist" = FALSE)
  )


  # nonsense library - no {testthat} in there!
  expect_false(is_installed("testthat", lib.loc = "thislibdoesnotexist"))

})

Try the suggests package in your browser

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

suggests documentation built on Aug. 8, 2023, 5:13 p.m.