Skip to content

Commit

Permalink
Merge pull request #47 from njtierney/covr-check-pkg-installed-46
Browse files Browse the repository at this point in the history
Add test coverage for check_pkg_installed
  • Loading branch information
njtierney authored Mar 24, 2024
2 parents 3429b79 + 8b48c44 commit 66d027d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
- uses: r-lib/actions/check-r-package@v2.8.3
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
4 changes: 1 addition & 3 deletions R/tar-terra-vect.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,7 @@ create_format_terra_vect <- function(filetype, options, ...) {

drv <- get_gdal_available_driver_list("vector")

if (is.null(filetype)) {
filetype <- "GeoJSON"
}
filetype <- filetype %||% "GeoJSON"

filetype <- match.arg(filetype, drv$name)

Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/_snaps/check-pkg-installed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# check_pkg_installed() works

Code
check_pkg_installed("asdf")
Condition
Error:
! package asdf is required

7 changes: 7 additions & 0 deletions tests/testthat/test-check-pkg-installed.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
test_that("check_pkg_installed() works", {
expect_snapshot(
error = TRUE,
x = check_pkg_installed("asdf")
)
expect_null(check_pkg_installed("targets"))
})

0 comments on commit 66d027d

Please sign in to comment.