Skip to content

Commit

Permalink
Add tests for RosvDownload similar to other low level functions
Browse files Browse the repository at this point in the history
  • Loading branch information
al-obrien committed Nov 22, 2023
1 parent 7475dd0 commit f3a6c0f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/testthat/test-RosvDownload.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
without_internet({
test_that("Can create a well-formed RosvDownload object...", {
rosv_dl_obj <- RosvDownload$new('RSEC-2023-6', ecosystem = 'CRAN')
expect_equal(rosv_dl_obj$request, "https://osv-vulnerabilities.storage.googleapis.com/CRAN/RSEC-2023-6.json")

rosv_dl_obj_all <- RosvDownload$new(ecosystem = 'CRAN')
expect_equal(rosv_dl_obj_all$request, "https://osv-vulnerabilities.storage.googleapis.com/CRAN/all.zip")
})
})

without_internet({
test_that("Check error checking on RosvDownload objects...", {

# Must be character vector and ecosystem provided
expect_error(RosvDownload$new(vuln_ids = 11111))
expect_error(RosvDownload$new(vuln_ids = NA_character_))
expect_error(RosvDownload$new(vuln_ids = c('RSEC-2023-6', NA_character_)))
expect_error(RosvDownload$new(vuln_ids = c('RSEC-2023-6', 'RSEC-2023-6'), ecosystem = 'cRAN'))
expect_no_error(RosvDownload$new(vuln_ids = c('RSEC-2023-6', 'RSEC-2023-6'), ecosystem = 'CRAN'))

})
})

0 comments on commit f3a6c0f

Please # to comment.