diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index d8147a3..1e230d5 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -40,9 +40,7 @@ Notes for contributors: - If `GITHUB_TOKEN` is available in the environment, it also checks that the example returns the expected output when run against the real API. This is configured automatically in GitHub Actions, but you can also use a [personal access token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) with no scopes. There's no need for this to cover anything in particular; it's just to make sure the example in fact works. - Tests should use `testify/assert` and `testify/require` where convenient (when making many simple assertions). -If you update any code-generation logic or templates, even if no new tests are needed you'll likely need to: -- Run `UPDATE_SNAPSHOTS=1 go test ./...` to update the [cupaloy](https://github.com/bradleyjkemp/cupaloy) snapshots. -- Run `go generate ./...` to update the genqlient-generated files used in integration tests and documentation. +If you update any code-generation logic or templates, even if no new tests are needed you'll likely need to run `UPDATE_SNAPSHOTS=1 go test ./...` to update the [cupaloy](https://github.com/bradleyjkemp/cupaloy) snapshots and the genqlient-generated files used in integration tests and documentation. ## Finding your way around diff --git a/internal/integration/util.go b/internal/integration/util.go index 0523d27..0e0a512 100644 --- a/internal/integration/util.go +++ b/internal/integration/util.go @@ -51,6 +51,14 @@ func RunGenerateTest(t *testing.T, relConfigFilename string) { if testing.Verbose() { t.Errorf("got:\n%s\nwant:\n%s\n", content, expectedContent) } + if os.Getenv("UPDATE_SNAPSHOTS") == "1" { + err = os.WriteFile(filename, content, 0o644) + if err != nil { + t.Errorf("unable to update generated file %s: %v", filename, err) + } else { + t.Errorf("updated generated file for %s", filename) + } + } } } }