-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathtest_tidylog.R
36 lines (29 loc) · 1.27 KB
/
test_tidylog.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
context("test_tidylog")
test_that("tidylog", {
f <- function() tidylog::tidylog(mtcars)
expect_message(f(), regexp = "data\\.frame.*32 rows.*11 columns")
f <- function() tidylog::tidylog(as_tibble(mtcars))
expect_message(f(), regexp = "tibble.*32 rows.*11 columns")
f <- function() tidylog::tidylog(group_by(mtcars, cyl, mpg))
expect_message(f(), regexp = "grouped tibble.*32 rows.*11 columns")
})
test_that("logging on/off", {
options("tidylog.display" = list())
expect_silent(tidylog::filter(mtcars, mpg > 20))
expect_silent(tidylog::select(mtcars, mpg))
expect_silent(tidylog::group_by(mtcars, mpg))
expect_silent(tidylog::left_join(dplyr::band_members, dplyr::band_instruments, by = "name"))
expect_silent(tidylog::mutate(mtcars, test = TRUE))
expect_silent(tidylog::summarize(mtcars, test = TRUE))
expect_silent(tidylog::gather(mtcars))
expect_silent(tidylog::spread(mtcars, cyl, hp))
expect_silent(tidylog::tidylog(mtcars))
# warnings
options("tidylog.display" = "x")
expect_warning(filter(mtcars, mpg > 20))
options("tidylog.display" = list("x", message))
expect_warning(filter(mtcars, mpg > 20))
# back to default
options("tidylog.display" = NULL)
expect_message(filter(mtcars, mpg > 20))
})