tests/testthat/test-audit.R

test_that("Test audit_deps", {
  skip_on_cran()

  # Test edge cases
  deps = audit(pkg = character(0), version = character(0), type = "cran")
  expect_equal(nrow(deps), 0)
  expect_equal(ncol(deps), 8)
  deps = audit(pkg = NULL, version = NULL, type = "cran")
  expect_equal(nrow(deps), 0)
  expect_equal(ncol(deps), 8)

  # Pass explicit packages
  # Also test missing versions, and mixing numbers and characters
  deps = expect_message(audit(pkg = c("abind", "acepack", "abind", "abind", "abind"),
                              version = c("1.4-5", "1.4.1", NA, "", 1),
                              type = "cran"))
  expect_equal(nrow(deps), 5)
  expect_equal(ncol(deps), 8)

  ## Ensure that no cases have the same colnames
  no_cases = no_purls_case()
  expect_true(all(colnames(no_cases) %in% colnames(deps)))

  vul = get_vulnerabilities(deps)
  expect_equal(nrow(vul), 0)
  expect_equal(ncol(vul), 14)

  # Basic checks on argument passing
  expect_error(audit(pkg = c("abind", "acepack"), version = "1.4-5", type = "cran"))
  expect_error(audit(pkg = "abind", version = "1.4-5", type = c("cran", "python")))
})
sonatype-nexus-community/oysteR documentation built on May 22, 2021, 3:34 a.m.