tests/testthat/test-basics.R

context("basics")

adaptalint_path <- system.file(package = "adaptalint")
filepath <- system.file('extdata', 'styles.R', package='adaptalint')

test_that("exports are correct", {
  expect_equal(find('extract_style'), 'package:adaptalint')
  expect_equal(find('lint_with_style'), 'package:adaptalint')
  expect_equal(find('extract_package_style'), 'package:adaptalint')
  expect_equal(find('lint_package_with_style'), 'package:adaptalint')
})

test_that("extract from package works in simple case", {
  a <- extract_package_style(adaptalint_path)
  expect_is(a, 'data.frame')
})

test_that("apply to package works in simple case", {
  data("style_dplyr")

  a <- lintr::lint_package(adaptalint_path)
  b <- lint_package_with_style(adaptalint_path, style_dplyr)
  expect_is(a, 'lints')
  expect_is(b, 'lints')
  expect_lte(length(b), length(a))
})

test_that('extract works in simple case', {
  a <- extract_style(filepath)
  expect_is(a, 'data.frame')
})

test_that("apply works in simple case", {
  data("style_dplyr")

  a <- lintr::lint(filepath)
  b <- lint_with_style(filepath, style_dplyr)
  expect_is(a, 'lints')
  expect_is(b, 'lints')
  expect_lte(length(b), length(a))
})

Try the adaptalint package in your browser

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

adaptalint documentation built on Oct. 5, 2019, 9:05 a.m.