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

Expose golden.flagUpdate with a golden.FlagUpdate method #205

Closed
odsod opened this issue Jul 15, 2020 · 1 comment · Fixed by #206
Closed

Expose golden.flagUpdate with a golden.FlagUpdate method #205

odsod opened this issue Jul 15, 2020 · 1 comment · Fixed by #206

Comments

@odsod
Copy link
Contributor

odsod commented Jul 15, 2020

For golden file tests that want to perform custom assertions (for example read proto messages from a golden file and perform a comparison assertion on the parsed message) it would be useful to expose the flagUpdate variable, so that the same flag can be used for all golden file tests (redefining this flag results in a panic).

odsod added a commit to odsod/gotest.tools that referenced this issue Jul 15, 2020
Returns true when the -test.update-golden flag has been set.

Fixes: gotestyourself#205
odsod added a commit to odsod/gotest.tools that referenced this issue Jul 15, 2020
Returns true when the -test.update-golden flag has been set.

Fixes: gotestyourself#205
@dnephin
Copy link
Member

dnephin commented Jul 20, 2020

I think this may be related to #8 in some ways.

One thing I've done to handle this type of problem is this: https:/gotestyourself/gotestsum/blob/master/internal/text/testing.go#L12-L28, you can see it used here: https:/gotestyourself/gotestsum/blob/e2b19e158466ef6e6da12a3c7d0dd0fb825ac740/testjson/dotformat_test.go#L33-L34

By processing the actual value you can store it in the golden without needing to read the flag.

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 a pull request may close this issue.

2 participants