Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

transition expect_error() for snowflake backend #1547

Merged
merged 3 commits into from
Oct 31, 2024
Merged

Conversation

simonpcouch
Copy link
Collaborator

Related to the first checkbox in #1546 but does not close; a demo of what that PR would look like for all backends.

For snowflake, transition expect_error():

  • ...to snapshot when testing the error message
  • ...to classed error when testing an error from another package or an error thrown from a widely-used helper
  • ...to expect_no_error() (or no test) when regex = NA
  • Analogous story for expect_warning() and expect_message().

* ...to snapshot when testing the error message
* ...to classed error when testing an error from another package or an error thrown from a widely-used helper
* ...to `expect_no_error()` (or no test) when `regex = NA`
* Analogous story for `expect_warning()` and `expect_message()`.
R/utils-check.R Outdated
@@ -144,7 +144,7 @@ check_unsupported_arg <- function(x,

msg <- c(msg, i = allow_msg)
}
cli_abort(msg, call = call)
cli_abort(msg, call = call, class = "unsupported_arg_error")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe include the arg in the error object too?

I'd make the class start with dbplyr_. I'm have mixed feelings about including error in the class name (since it seems redundant) but I see that rlang includes it, so best to be conssitent?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DavisVaughan suggests using dbplyr_error_... to match vctrs.

)
expect_snapshot(
error = TRUE,
test_translate_sql(difftime(start_date, end_date, tz = "UTC", units = "days"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expectg_error(class = "unsupported_arg_error")?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woops, should have called this out in a self-review—these two lines transition from expect_error() to expect_snapshot() for one-off, unclassed errors where we're interested in testing the message specifically.

@simonpcouch simonpcouch merged commit ad8a9d9 into main Oct 31, 2024
13 checks passed
@simonpcouch simonpcouch deleted the cleaning-snowflake branch October 31, 2024 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants