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

Automatically update generated files if UPDATE_SNAPSHOTS=1 #243

Merged
merged 1 commit into from
Dec 22, 2022

Conversation

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 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.

I have:

  • Written a clear PR title and description (above)
  • Signed the Khan Academy CLA
  • Added tests covering my changes, if applicable
  • Included a link to the issue fixed, if applicable
  • Included documentation, for new features
  • Added an entry to the changelog

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.

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.
Copy link
Member

@csilvers csilvers left a comment

Choose a reason for hiding this comment

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

Makes sense to me!

Copy link
Member

@StevenACoffman StevenACoffman left a comment

Choose a reason for hiding this comment

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

Yay! @kevinbarabash This is the behavior I think you were looking for in webapp, right?

@benjaminjkraft benjaminjkraft merged commit b1adeca into main Dec 22, 2022
@benjaminjkraft benjaminjkraft deleted the benkraft.update-generated branch December 22, 2022 07:19
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.

Auto-update generated files if UPDATE_SNAPSHOTS=1 is set
3 participants