tests/testthat/test-name.R

context("check name")

test_that("name already exists", {
    withr::with_environment(.GlobalEnv, {
        .test_cab <<- NULL
        expect_error(check_name("test_cab"))
        rm(.test_cab, envir = .GlobalEnv)
    })
})

test_that("name doesn't exist", {
    withr::with_environment(.GlobalEnv, {
        cli::cli_div(theme = list(".alert-success" = list(before = "PASSING ")))
        verify_output(test_path("test-name-doesnt-exist.txt"), {
            check_name("test_cab")
        })
    })
})

Try the cabinets package in your browser

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

cabinets documentation built on Nov. 8, 2020, 4:32 p.m.