-
Notifications
You must be signed in to change notification settings - Fork 314
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
Add replace argument to expect_snapshot() #1345
Comments
I ended up needing to do quite a bit of this in gargle, because of temp paths that vary, token hashes that vary by OS or R version, random backoff waiting times, etc. Observations to guide implementation:
|
Here's a real example of the basic form I used that also happens to illustrate most of the above: out <- capture.output(
gargle_oauth_sitrep(tmp_cache),
type = "message"
)
out <- sub(tmp_cache, "{path to gargle oauth cache}", out, fixed = TRUE)
out <- sub("[[:xdigit:]]{7}[.]{3}", "{hash...}", out)
expect_snapshot(
writeLines(out)
) One big bummer about the workaround is that the code in your snapshot ends up being completely uninformative ( |
I think we'd default to Could we just disallow replacing with ""? You could always just do |
Well I have a piece of text that may or may not appear, so no. (Obviously one could also examine the problem from the other direction and rethink the message.) |
Ooooh I didn't think of that case. |
May be better to leave completely generic: expect_snapshot(
gargle_oauth_sitrep(tmp_cache),
redact = function(x) {
x <- sub(tmp_cache, "{path to gargle oauth cache}", x, fixed = TRUE)
x <- sub("[[:xdigit:]]{7}[.]{3}", "{hash...}", x)
x
}
) |
Here's where things have evolved to in googledrive: So I have these two scrubbers and use them in many tests. I can imagine this being a common pattern. So, yes, it would be nice to have a way to apply custom scrubbers inside |
To make it easier to scrub sensitive and stochastic output Fixes #1345
For when you have sensitive or random components:
The text was updated successfully, but these errors were encountered: