tests/testthat/test-check_tibble.R

context("test-check_tibble")

library(tibble)

test_that("strict = FALSE", {

  expect_silent(check_tibble(tibble(), strict = FALSE))

  expect_error(check_tibble(data.frame(), strict = FALSE))
  expect_error(check_tibble(list(), strict = FALSE))
  expect_error(check_tibble(1L, strict = FALSE))
})

test_that("strict = TRUE", {

  df <- tibble(
    term = letters[1:5],
    estimate = rnorm(5),
    invalid_name = 1:5
  )

  expect_error(
    check_tibble(df, method = "tidy", strict = TRUE),
    "Output column names not in the column glossary: invalid_name"
  )

  expect_silent(
    check_tibble(
      df,
      method = "tidy",
      columns = c("term", "estimate"),
      strict = TRUE
    )
  )
})

Try the modeltests package in your browser

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

modeltests documentation built on Jan. 16, 2021, 5:38 p.m.