forked from r-lib/usethis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for
use_data_table()
(r-lib#994)
* add tests for `use_data_table()` * remove context and mock install data.table
- Loading branch information
1 parent
c31336d
commit 48dfa2a
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
test_that("use_data_table() requires a package", { | ||
scoped_temporary_project() | ||
expect_usethis_error(use_data_table(), "not an R package") | ||
}) | ||
|
||
test_that("use_data_table() Imports data.table", { | ||
with_mock( | ||
`usethis:::uses_roxygen` = function(base_path) TRUE, | ||
`usethis:::is_installed` = function(pkg) TRUE, { | ||
scoped_temporary_package() | ||
use_data_table() | ||
expect_match(desc::desc_get("Imports", proj_get()), "data.table") | ||
datatable_doc <- readLines(proj_path("R", "utils-data-table.R")) | ||
expect_match(datatable_doc, "#' @import data.table", all = FALSE) | ||
} | ||
) | ||
}) | ||
|
||
|