Skip to content

Commit

Permalink
Fix TestPipelineLevelFinally_OneDAGTaskFailed test to avoid false neg…
Browse files Browse the repository at this point in the history
…ative 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 <yulia.gaponenko1@de.ibm.com>
  • Loading branch information
barthy1 authored and tekton-robot committed Jan 27, 2021
1 parent fbbcf71 commit d4a3aa2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion test/pipelinefinally_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package test

import (
"context"
"sort"
"strings"
"testing"

Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit d4a3aa2

Please sign in to comment.