Skip to content

Commit 8e7bfc9

Browse files
Use public interface to test internal functions: Part-4 (#1774)
* Use public interface to test internal functions: Part-4 Part of #1692 * fix lints * check also the location * fix URL * fix for windows? * Use `winslash = "/"`
1 parent 4aed6d5 commit 8e7bfc9

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

tests/testthat/test-methods.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ test_that("as.data.frame.lints", {
5656
# Convert lints to data.frame
5757
lints <- structure(list(l1, l2), class = "lints")
5858
expect_s3_class(
59-
df <- lintr:::as.data.frame.lints(lints),
59+
df <- as.data.frame(lints),
6060
"data.frame"
6161
)
6262

tests/testthat/test-use_lintr.R

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,34 @@ test_that("use_lintr works as expected", {
44
lintr_file <- use_lintr(path = tmp)
55
expect_true(file.exists(lintr_file))
66

7+
# check that newly created file is in the root directory
8+
expect_identical(
9+
normalizePath(lintr_file, winslash = "/"),
10+
file.path(normalizePath(tmp, winslash = "/"), ".lintr")
11+
)
12+
713
# can't generate if a .lintr already exists
814
expect_error(use_lintr(path = tmp), "Found an existing configuration")
915

10-
# read_settings() works with the generated file
11-
expect_silent(lintr:::read_settings(tmp))
12-
lintr:::read_settings(NULL)
13-
14-
expect_identical(
15-
normalizePath(lintr:::find_config(tmp)),
16-
normalizePath(lintr_file)
17-
)
16+
# check that `read_settings()` works with the generated file
17+
# this can be checked by checking lintr runs successfully
18+
lints <- lint_dir(tmp)
19+
expect_length(lints, 0L)
1820
})
1921

2022
test_that("use_lintr with type = full also works", {
2123
tmp <- withr::local_tempdir()
2224

2325
# type = "full" also works with read_settings()
24-
use_lintr(path = tmp, type = "full")
25-
expect_silent(lintr:::read_settings(tmp))
26-
lintr:::read_settings(NULL)
26+
lintr_file <- use_lintr(path = tmp, type = "full")
27+
expect_true(file.exists(lintr_file))
28+
29+
# check that newly created file is in the root directory
30+
expect_identical(
31+
normalizePath(lintr_file, winslash = "/"),
32+
file.path(normalizePath(tmp, winslash = "/"), ".lintr")
33+
)
34+
35+
lints <- lint_dir(tmp)
36+
expect_length(lints, 0L)
2737
})

0 commit comments

Comments
 (0)