-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Document why toolsnap churn occurred between PR #1816 and subsequent PRs #1819
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -252,3 +252,63 @@ func TestToolSnapKeysSorted(t *testing.T) { | |||||
| assert.Greater(t, mmmIndex, aaaIndex, "mmm should come after aaa") | ||||||
| assert.Greater(t, zzzIndex, mmmIndex, "zzz should come after mmm") | ||||||
| } | ||||||
|
|
||||||
| func TestStructFieldOrderingSortedAlphabetically(t *testing.T) { | ||||||
| withIsolatedWorkingDir(t) | ||||||
|
|
||||||
| // Given a struct with fields defined in non-alphabetical order | ||||||
| // This test ensures that struct field order doesn't affect the JSON output | ||||||
| type toolWithNonAlphabeticalFields struct { | ||||||
| ZField string `json:"zField"` // Should appear last in JSON | ||||||
| AField string `json:"aField"` // Should appear first in JSON | ||||||
| MField string `json:"mField"` // Should appear in the middle | ||||||
| } | ||||||
|
|
||||||
| tool := toolWithNonAlphabeticalFields{ | ||||||
| ZField: "z value", | ||||||
| AField: "a value", | ||||||
| MField: "m value", | ||||||
| } | ||||||
|
|
||||||
| // When we write the snapshot | ||||||
| t.Setenv("UPDATE_TOOLSNAPS", "true") | ||||||
| err := Test("struct_field_order", tool) | ||||||
| require.NoError(t, err) | ||||||
|
|
||||||
| // Then the snapshot file should have alphabetically sorted keys despite struct field order | ||||||
| snapJSON, err := os.ReadFile("__toolsnaps__/struct_field_order.snap") | ||||||
| require.NoError(t, err) | ||||||
|
|
||||||
| snapStr := string(snapJSON) | ||||||
|
|
||||||
| // Find the positions of each field in the JSON string | ||||||
| aFieldIndex := -1 | ||||||
| mFieldIndex := -1 | ||||||
| zFieldIndex := -1 | ||||||
| for i := 0; i < len(snapStr)-7; i++ { | ||||||
|
||||||
| for i := 0; i < len(snapStr)-7; i++ { | |
| for i := 0; i < len(snapStr)-5; i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description claims to add
TOOLSNAP_CHURN_EXPLANATION.mddocumenting why toolsnaps showed churn, but this file is not present in the changes. The documentation mentioned in the 'What changed' and 'Docs' sections of the PR description is missing. If documentation was intended to be added, it should be included in the PR.