Skip to content

Commit

Permalink
test optional=TRUE
Browse files Browse the repository at this point in the history
  • Loading branch information
kbvernon committed Nov 15, 2024
1 parent 530d2e7 commit a3dae97
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/testthat/test-use_crate.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,27 @@ test_that("use_crate() errors when user passes git and version arguments", {

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

test_that("use_crate(optional = TRUE) adds optional dependency", {
skip_if_not_installed("usethis")

path <- local_package("testpkg")

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

use_extendr(path, quiet = TRUE)

use_crate(
"serde",
optional = TRUE,
path = path
)

metadata <- read_cargo_metadata(path)

dependency <- metadata[["packages"]][["dependencies"]][[1]]
dependency <- dependency[dependency[["name"]] == "serde", ]

expect_identical(dependency[["optional"]], TRUE)
})

0 comments on commit a3dae97

Please sign in to comment.