Skip to content

Commit 13a3c5d

Browse files
jeroptekton-robot
authored andcommitted
Sort ChildReferences in tests
Prior to this change, the `ChildReferences` in tests were sorted by `PipelineTaskName`. With `Matrix` multiple `ChildReferences` could have the same `PipelineTaskName` - this causes the tests to be flakey because the slices are not always sorted the same way. In this change, we sort the slices of `ChildReferences` by the name of the `ChildReferences` - mapping to names of `TaskRuns` or `Runs`. This ensures the slices are always sorted the same way, and removes the flakes.
1 parent 1755579 commit 13a3c5d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pkg/reconciler/pipelinerun/pipelinerun_updatestatus_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,10 @@ pipelineTaskName: task
790790

791791
// Sort the ChildReferences to deal with annoying ordering issues.
792792
sort.Slice(actualPrStatus.ChildReferences, func(i, j int) bool {
793-
return actualPrStatus.ChildReferences[i].PipelineTaskName < actualPrStatus.ChildReferences[j].PipelineTaskName
793+
return actualPrStatus.ChildReferences[i].Name < actualPrStatus.ChildReferences[j].Name
794+
})
795+
sort.Slice(tc.expectedPrStatus.ChildReferences, func(i, j int) bool {
796+
return tc.expectedPrStatus.ChildReferences[i].Name < tc.expectedPrStatus.ChildReferences[j].Name
794797
})
795798

796799
if d := cmp.Diff(tc.expectedPrStatus, actualPrStatus); d != "" {

0 commit comments

Comments
 (0)