File: test-data-table.R

package info (click to toggle)
r-cran-usethis 3.1.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,228 kB
  • sloc: sh: 26; makefile: 17; cpp: 6; ansic: 3
file content (37 lines) | stat: -rw-r--r-- 912 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
test_that("use_data_table() requires a package", {
  create_local_project()
  expect_usethis_error(use_data_table(), "not an R package")
})

test_that("use_data_table() Imports data.table", {
  create_local_package()
  use_package_doc()
  local_check_installed()
  local_roxygen_update_ns()
  local_check_fun_exists()

  use_data_table()

  expect_match(proj_desc()$get("Imports"), "data.table")
  expect_snapshot(roxygen_ns_show())
})

test_that("use_data_table() blocks use of Depends", {
  local_interactive(FALSE)

  create_local_package()
  use_package_doc()
  desc::desc_set("Depends", "data.table")
  local_check_installed()
  local_roxygen_update_ns()
  local_check_fun_exists()

  withr::local_options(list(usethis.quiet = FALSE))
  expect_snapshot(
    use_data_table(),
    transform = scrub_testpkg
  )

  expect_match(desc::desc_get("Imports"), "data.table")
  expect_snapshot(roxygen_ns_show())
})