tests/testthat/test-errors.R

test_that("require furrr", {
  local_mock(
    requireNamespace = function(x, ...) {if (x == "furrr") {FALSE} else {TRUE}}
  )
  expect_error(future_xmap(list(1:3, 1:3), paste))
})

test_that("require future", {
  local_mock(
    requireNamespace = function(x, ...) {if (x == "future") {FALSE} else {TRUE}}
  )
  expect_error(future_xmap(list(1:3, 1:3), paste))
})

test_that("message for no plan", {
  local_mock(
    plan = function(...) {NULL},
    .env = "future"
  )
  expect_message(require_furrr(), "not set up to run background processes")
})

test_that("message for single core", {
  local_mock(
    availableCores = function(...) {1},
    .env = "future"
  )
  expect_message(require_furrr(), "not set up to run background processes")
})

Try the crossmap package in your browser

Any scripts or data that you put into this service are public.

crossmap documentation built on Jan. 13, 2023, 1:13 a.m.