Skip to content

Commit

Permalink
test for error
Browse files Browse the repository at this point in the history
  • Loading branch information
kbvernon committed Nov 14, 2024
1 parent cc062d9 commit 530d2e7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion R/use_crate.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ use_crate <- function(

if (!is.null(version) && !is.null(git)) {
cli::cli_abort(
"Cannot specify a git URL ('{git}') with a version ('{version}')."
"Cannot specify a git URL ('{git}') with a version ('{version}').",
class = "rextendr_error"
)
}

Expand Down
21 changes: 21 additions & 0 deletions tests/testthat/test-use_crate.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,24 @@ test_that("use_crate() adds dependency to package or workspace", {

expect_equal(dependency[["req"]], "^1.0.1")
})

test_that("use_crate() errors when user passes git and version arguments", {
skip_if_not_installed("usethis")

path <- local_package("testpkg")

# capture setup messages
withr::local_options(usethis.quiet = FALSE)

use_extendr(path, quiet = TRUE)

fn <- function() {
use_crate(
"serde",
git = "https://github.com/serde-rs/serde",
version = "1.0.1"
)
}

expect_error(fn(), class = "rextendr_error")
})

0 comments on commit 530d2e7

Please sign in to comment.