Skip to content

Commit

Permalink
add tests for use_data_table() (r-lib#994)
Browse files Browse the repository at this point in the history
* add tests for `use_data_table()`

* remove context and mock install data.table
  • Loading branch information
malcolmbarrett authored Jan 31, 2020
1 parent c31336d commit 48dfa2a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/testthat/test-use-data-table.R
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)
}
)
})


0 comments on commit 48dfa2a

Please sign in to comment.