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

Auto-update generated files if UPDATE_SNAPSHOTS=1 is set #212

Closed
benjaminjkraft opened this issue Jul 28, 2022 · 0 comments · Fixed by #243
Closed

Auto-update generated files if UPDATE_SNAPSHOTS=1 is set #212

benjaminjkraft opened this issue Jul 28, 2022 · 0 comments · Fixed by #243
Labels
good first issue Good for newcomers help wanted Issues that anyone could pick up and implement if useful to them internal

Comments

@benjaminjkraft
Copy link
Collaborator

If you do UPDATE_SNAPSHOTS=1 go test ./... that will:

  1. run the snapshot tests, updating any changed snapshots
  2. run the integration tests and (if you have tokens) example tests
  3. check that the code for the integration tests and example tests is up-to-date

Step 3 is not strictly a snapshot test; the generated code is actually checked in and used. But, I mean, it's basically the same! So we should probably update it in the same places; if you need to update the snapshots you also probably need to update the integration tests. It's a little weirder because you'll also now need to re-run them (since they test things other than the snapshots) but that's probably ok.

@benjaminjkraft benjaminjkraft added good first issue Good for newcomers help wanted Issues that anyone could pick up and implement if useful to them internal labels Jul 28, 2022
benjaminjkraft added a commit that referenced this issue Dec 22, 2022
If you do `UPDATE_SNAPSHOTS=1 go test ./...` that will:
1. run the snapshot tests, updating any changed snapshots
2. run the integration tests and (if you have tokens) example tests
3. check that the code for the integration tests and example tests is
up-to-date

Step 3 is not strictly a snapshot test; the generated code is actually
checked in and used. But, I mean, it's basically the same! So now, we
also update it if you asked to update snapshots, which is hopefully a
little more convenient.

Fixes #212.

Test plan:
Make a trivial change to `example/generated.go`; `go test ./...` should
now fail. `UPDATE_SNAPSHOTS=1 go test ./...` should also fail, but say
it updated the snapshot, and the change should be reverted. Run `go test
./...` again; it should pass again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Issues that anyone could pick up and implement if useful to them internal
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant