Skip to content

Commit

Permalink
🐛 Add tie breaker when sorting changesets by RevisionID in tests. (os…
Browse files Browse the repository at this point in the history
…sf#2781)

* Remove duplicate RevisionID collision from changeset tests.

The map iteration order isn't deterministic and sorting the slices isn't good enough when the revision IDs are equal.

Signed-off-by: Spencer Schrock <sschrock@google.com>

* remove any potential sha collisions

Signed-off-by: Spencer Schrock <sschrock@google.com>

* Revert deduplications.

Signed-off-by: Spencer Schrock <sschrock@google.com>

* Use ReviewPlatform as tie breaker.

Signed-off-by: Spencer Schrock <sschrock@google.com>

---------

Signed-off-by: Spencer Schrock <sschrock@google.com>
Signed-off-by: Avishay <avishay.balter@gmail.com>
  • Loading branch information
spencerschrock authored and balteravishay committed Apr 14, 2023
1 parent 41bc7b2 commit 2411511
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions checks/raw/code_review_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ func Test_getChangesets(t *testing.T) {
changesets := getChangesets(tt.commits)
if !cmp.Equal(tt.expected, changesets,
cmpopts.SortSlices(func(x, y checker.Changeset) bool {
if x.RevisionID == y.RevisionID {
return x.ReviewPlatform < y.ReviewPlatform
}
return x.RevisionID < y.RevisionID
}),
cmpopts.SortSlices(func(x, y clients.Commit) bool {
Expand Down

0 comments on commit 2411511

Please sign in to comment.