Skip to content

Commit

Permalink
MINOR: Move tests, skip when no dataset is available (apache#42233)
Browse files Browse the repository at this point in the history
Update tests that are making our minimal builds fail. The tests are unchanged and no new functionality is added. I moved the tests that were failing to the end of their blocks and added `skip_if_not_available("dataset")` since our minimal builds _don't_ include datasets and thus the snapshots that use datasets will be wrong there.

Authored-by: Jonathan Keane <[email protected]>
Signed-off-by: Jonathan Keane <[email protected]>
  • Loading branch information
jonkeane authored Jun 21, 2024
1 parent 3711657 commit 5e52077
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
17 changes: 9 additions & 8 deletions r/tests/testthat/test-dplyr-across.R
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,6 @@ test_that("expand_across correctly expands quosures", {
example_data
)

# ellipses (...) are a deprecated argument
# abandon_ship message offers multiple suggestions
expect_snapshot(
InMemoryDataset$create(example_data) %>%
mutate(across(c(dbl, dbl2), round, digits = -1)),
error = TRUE
)

# alternative ways of specifying .fns - as a list
expect_across_equal(
quos(across(1:dbl2, list(round))),
Expand Down Expand Up @@ -230,6 +222,15 @@ test_that("expand_across correctly expands quosures", {
),
example_data
)

skip_if_not_available("dataset")
# ellipses (...) are a deprecated argument
# abandon_ship message offers multiple suggestions
expect_snapshot(
InMemoryDataset$create(example_data) %>%
mutate(across(c(dbl, dbl2), round, digits = -1)),
error = TRUE
)
})

test_that("purrr-style lambda functions are supported", {
Expand Down
1 change: 1 addition & 0 deletions r/tests/testthat/test-dplyr-eval.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ test_that("try_arrow_dplyr/abandon_ship adds the right message about collect()",
})
}

skip_if_not_available("dataset")
ds <- InMemoryDataset$create(arrow_table(x = 1))
for (i in 0:2) {
expect_snapshot(tester(ds, i), error = TRUE)
Expand Down
31 changes: 16 additions & 15 deletions r/tests/testthat/test-dplyr-funcs-datetime.R
Original file line number Diff line number Diff line change
Expand Up @@ -1885,21 +1885,6 @@ test_that("`as.Date()` and `as_date()`", {
test_df
)

# we do not support multiple tryFormats
# Use a dataset to test the alternative suggestion message
expect_snapshot(
test_df %>%
InMemoryDataset$create() %>%
transmute(
date_char_ymd = as.Date(
character_ymd_var,
tryFormats = c("%Y-%m-%d", "%Y/%m/%d")
)
) %>%
collect(),
error = TRUE
)

# strptime does not support a partial format - Arrow returns NA, while
# lubridate parses correctly
# TODO: revisit after ARROW-15813
Expand Down Expand Up @@ -1957,6 +1942,22 @@ test_that("`as.Date()` and `as_date()`", {
collect(),
test_df
)

skip_if_not_available("dataset")
# we do not support multiple tryFormats
# Use a dataset to test the alternative suggestion message
expect_snapshot(
test_df %>%
InMemoryDataset$create() %>%
transmute(
date_char_ymd = as.Date(
character_ymd_var,
tryFormats = c("%Y-%m-%d", "%Y/%m/%d")
)
) %>%
collect(),
error = TRUE
)
})

test_that("`as_date()` and `as.Date()` work with R objects", {
Expand Down

0 comments on commit 5e52077

Please sign in to comment.