Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
kbvernon committed Nov 9, 2024
1 parent 5c2b879 commit e24b7b3
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/testthat/test-use_crate.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
test_that("use_crate() adds dependency to package or workspace", {
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",
features = "derive",
git = "https://github.com/serde-rs/serde",
version = "1.0.1"
)

metadata <- read_cargo_metadata(path)

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

expect_equal(dependency[["name"]], "serde")

expect_equal(dependency[["features"]], "derive")

expect_equal(dependency[["source"]], "git+https://github.com/serde-rs/serde")

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

0 comments on commit e24b7b3

Please sign in to comment.