Skip to content

Commit

Permalink
Use lifecycle instead of tibble (#2080)
Browse files Browse the repository at this point in the history
* Use lifecycle instead of tibble

waldo previously imported tibble so switch to a package that will always be installed with usethis.

* Change another test

---------

Co-authored-by: Jenny Bryan <[email protected]>
  • Loading branch information
hadley and jennybc authored Nov 6, 2024
1 parent c63c6e8 commit 50dcb10
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions tests/testthat/_snaps/use_import_from.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Code
roxygen_ns_show()
Output
[1] "#' @importFrom tibble deframe" "#' @importFrom tibble enframe"
[3] "#' @importFrom tibble tibble"
[1] "#' @importFrom lifecycle deprecate_stop"
[2] "#' @importFrom lifecycle deprecate_warn"

# use_import_from() generates helpful errors

Expand All @@ -14,15 +14,15 @@
Error in `use_import_from()`:
x `package` must be a single string.
Code
use_import_from(c("tibble", "rlang"))
use_import_from(c("desc", "rlang"))
Condition
Error in `use_import_from()`:
x `package` must be a single string.
Code
use_import_from("tibble", "pool_noodle")
use_import_from("desc", "pool_noodle")
Condition
Error in `map2()`:
i In index: 1.
Caused by error in `.f()`:
x Can't find `tibble::pool_noodle()`.
x Can't find `desc::pool_noodle()`.

12 changes: 6 additions & 6 deletions tests/testthat/test-use_import_from.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
test_that("use_import_from() imports the related package & adds line to package doc", {
create_local_package()
use_package_doc()
use_import_from("tibble", "tibble")
use_import_from("lifecycle", "deprecated")

expect_equal(proj_desc()$get_field("Imports"), "tibble")
expect_equal(roxygen_ns_show(), "#' @importFrom tibble tibble")
expect_equal(proj_desc()$get_field("Imports"), "lifecycle")
expect_equal(roxygen_ns_show(), "#' @importFrom lifecycle deprecated")
})

test_that("use_import_from() adds one line for each function", {
create_local_package()
use_package_doc()
use_import_from("tibble", c("tibble", "enframe", "deframe"))
use_import_from("lifecycle", c("deprecate_warn", "deprecate_stop"))

expect_snapshot(roxygen_ns_show())
})
Expand All @@ -21,8 +21,8 @@ test_that("use_import_from() generates helpful errors", {

expect_snapshot(error = TRUE, {
use_import_from(1)
use_import_from(c("tibble", "rlang"))
use_import_from(c("desc", "rlang"))

use_import_from("tibble", "pool_noodle")
use_import_from("desc", "pool_noodle")
})
})

0 comments on commit 50dcb10

Please sign in to comment.