Skip to content

Add WithUpdateEnv option to protect fixtures from blanket updates#219

Open
abiduke612 wants to merge 1 commit intomainfrom
abbyduke/protect-golden-fixtures
Open

Add WithUpdateEnv option to protect fixtures from blanket updates#219
abiduke612 wants to merge 1 commit intomainfrom
abbyduke/protect-golden-fixtures

Conversation

@abiduke612
Copy link
Copy Markdown
Collaborator

@abiduke612 abiduke612 commented Apr 9, 2026

  • Update error hint message in CompareWithFixture to use the resolved updateEnv variable instead of hardcoded UPDATE=true
  • Update function comment to reflect that the env var name is configurable via WithUpdateEnv

Copilot AI review requested due to automatic review settings April 9, 2026 00:34
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a configurable environment variable name for golden fixture updates so tests can opt out of blanket UPDATE-driven fixture rewrites.

Changes:

  • Add UpdateEnv to testutil.CompareWithFixture options, defaulting to UPDATE.
  • Introduce WithUpdateEnv(...) option to override which env var triggers fixture updates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread testutil/golden.go Outdated
Comment thread testutil/golden.go
Copilot AI review requested due to automatic review settings April 15, 2026 23:45
@abiduke612 abiduke612 force-pushed the abbyduke/protect-golden-fixtures branch from 50d3c4f to 19e98e3 Compare April 15, 2026 23:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread testutil/golden.go
t.Fatalf("failed to get absolute path to testdata file: %v", err)
}
if os.Getenv("UPDATE") != "" {
if os.Getenv(options.UpdateEnv) != "" {
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

CompareWithFixture now checks os.Getenv(options.UpdateEnv) for updating fixtures, but the diff failure hint later in the function still instructs users to run with UPDATE=true .... This becomes misleading when WithUpdateEnv(...) is used; format the hint using the resolved options.UpdateEnv value (and consider using a non-empty example value like =1 since the check is != "").

Copilot uses AI. Check for mistakes.
Comment thread testutil/golden.go
Comment on lines +105 to +109
func WithUpdateEnv(env string) option {
return func(opts *options) {
opts.UpdateEnv = env
}
}
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

This PR introduces WithUpdateEnv, but the CompareWithFixture doc comment still says fixtures are updated by setting the UPDATE env var. Update the comment to reflect that the env var name is configurable (defaulting to UPDATE) so callers know to use WithUpdateEnv when needed.

Copilot uses AI. Check for mistakes.
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.

3 participants