Test when datamation_sanddance errors
This commit is contained in:
Родитель
8e75e7fc30
Коммит
1d6824f7fe
|
@ -19,13 +19,13 @@ datamation_sanddance <- function(pipeline, envir = rlang::global_env(), pretty =
|
|||
supported_tidy_functions <- c("group_by", "summarize", "summarise")
|
||||
|
||||
fittings <- pipeline %>%
|
||||
parse_pipeline()
|
||||
parse_pipeline(supported_tidy_functions)
|
||||
|
||||
data_states <- fittings %>%
|
||||
snake(envir = envir)
|
||||
|
||||
if (length(data_states) < 2) {
|
||||
stop("No data transformation detected by datamation_tibble", call. = FALSE)
|
||||
stop("No data transformation detected by `datamation_sanddance`.", call. = FALSE)
|
||||
}
|
||||
|
||||
tidy_functions_list <- parse_functions(fittings)
|
||||
|
@ -37,7 +37,7 @@ datamation_sanddance <- function(pipeline, envir = rlang::global_env(), pretty =
|
|||
map(
|
||||
tidy_functions_list,
|
||||
~ if (!(.x %in% supported_tidy_functions)) {
|
||||
stop(paste(.x, "not supported by datamation_sanddance"), call. = FALSE)
|
||||
stop(paste(.x, "is not supported by `datamation_sanddance`"), call. = FALSE)
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -27,3 +27,11 @@ test_that("datamation_sanddance returns a frame for the data, one for each group
|
|||
expect_length(specs[["group_by"]], 2)
|
||||
expect_length(specs[["summarize"]], 2)
|
||||
})
|
||||
|
||||
test_that("datamation_sanddance errors when no data transformation is present", {
|
||||
expect_error(datamation_sanddance("mtcars"), "data transformation")
|
||||
})
|
||||
|
||||
test_that("datamation_sanddance errors when an unsupported function is passed", {
|
||||
expect_error(datamation_sanddance("palmerpenguins::penguins %>% group_by(species) %>% ungroup()", "not supported by"))
|
||||
})
|
||||
|
|
Загрузка…
Ссылка в новой задаче