From d4a3aa2ec86e4711490d24fa185502da794ef426 Mon Sep 17 00:00:00 2001 From: Yulia Gaponenko Date: Wed, 27 Jan 2021 11:19:32 +0100 Subject: [PATCH] Fix TestPipelineLevelFinally_OneDAGTaskFailed test to avoid false negative error For TestPipelineLevelFinally_OneDAGTaskFailed_InvalidTaskResult_Failure list of skipped tasks is checked. In case if order of actual skipped tasks is different then expected, test fails despite equality between actual and expected skipped tasks. Sort of actual skipped tasks order based on their names will fix this problem. Signed-off-by: Yulia Gaponenko --- test/pipelinefinally_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/pipelinefinally_test.go b/test/pipelinefinally_test.go index 2eaecefeb32..e74c68ac4d1 100644 --- a/test/pipelinefinally_test.go +++ b/test/pipelinefinally_test.go @@ -17,6 +17,7 @@ package test import ( "context" + "sort" "strings" "testing" @@ -284,7 +285,11 @@ func TestPipelineLevelFinally_OneDAGTaskFailed_InvalidTaskResult_Failure(t *test Name: "finaltaskconsumingdagtask4", }} - if d := cmp.Diff(pr.Status.SkippedTasks, expectedSkippedTasks); d != "" { + actualSkippedTasks := pr.Status.SkippedTasks + // Sort tasks based on their names to get similar order as in expected list + sort.Slice(actualSkippedTasks, func(i int, j int) bool { return actualSkippedTasks[i].Name < actualSkippedTasks[j].Name }) + + if d := cmp.Diff(actualSkippedTasks, expectedSkippedTasks); d != "" { t.Fatalf("Expected four skipped tasks, dag task with condition failure dagtask3, dag task with when expression,"+ "two final tasks with missing result reference finaltaskconsumingdagtask1 and finaltaskconsumingdagtask4 in SkippedTasks."+ " Diff: %s", diff.PrintWantGot(d))