fix(tests): sort snapshot cases correctly#734
Conversation
How to use the Graphite Merge QueueAdd the label 0-merge to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Pull request overview
This PR fixes deterministic snapshot output ordering by switching snapshot entry sorting from plain lexicographic ordering to a “natural” numeric-aware ordering (so invalid-2 sorts before invalid-10), and updates stored snapshots accordingly.
Changes:
- Replace
sort.Strings(keys)with a custom natural sort (sortSnapshotKeys) for snapshot entry keys. - Add unit tests covering numeric-aware ordering for both test-case indices (
invalid-N) and snapshot numbers (- N). - Regenerate/commit affected
.snapfiles with the new deterministic ordering.
Reviewed changes
Copilot reviewed 55 out of 56 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/rule_tester/snapshot.go | Introduces natural numeric key comparison and uses it when writing snapshot files. |
| internal/rule_tester/snapshot_test.go | Adds tests validating the new snapshot key ordering behavior. |
| internal/rule_tester/snapshots/*.snap | Reorders snapshot entries to match the new natural sort order. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merge activity
|
Previously: 0, 1, 10, 11, 12, 13... Now: 0, 1, 2, 3, 4, 5...
b3995fa to
112cf3e
Compare

Previously:
0, 1, 10, 11, 12, 13...
Now:
0, 1, 2, 3, 4, 5...