Skip to content

Commit

Permalink
Fix flaky unit tests
Browse files Browse the repository at this point in the history
This fixes the flaky unit tests, as they were failing
because of the order of the elements of array
  • Loading branch information
piyush-garg authored and chmouel committed Jan 5, 2024
1 parent 345c185 commit 021ec94
Show file tree
Hide file tree
Showing 20 changed files with 6,105 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ linters:
#- tagliatelle
- tenv
- testableexamples
- testifylint
# - testifylint
#- testpackage
#- thelper
- tparallel
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ require (
github.com/mitchellh/mapstructure v1.5.0
github.com/pkg/errors v0.9.1
github.com/spf13/cobra v1.8.0
github.com/stretchr/testify v1.8.4
github.com/tektoncd/pipeline v0.53.1
github.com/xanzy/go-gitlab v0.94.0
go.opencensus.io v0.24.0
Expand All @@ -47,6 +48,7 @@ require (
require (
github.com/antlr4-go/antlr/v4 v4.13.0 // indirect
github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
)

replace (
Expand Down
7 changes: 4 additions & 3 deletions pkg/kubeinteraction/status/task_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import (
testclient "github.com/openshift-pipelines/pipelines-as-code/pkg/test/clients"
"github.com/openshift-pipelines/pipelines-as-code/pkg/test/kubernetestint"
tektontest "github.com/openshift-pipelines/pipelines-as-code/pkg/test/tekton"
"github.com/stretchr/testify/assert"
tektonv1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
"go.uber.org/zap"
zapobserver "go.uber.org/zap/zaptest/observer"
"gotest.tools/v3/assert"
assertv3 "gotest.tools/v3/assert"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -293,11 +294,11 @@ func TestGetStatusFromTaskStatusOrFromAsking(t *testing.T) {
for _, prtrs := range statuses {
displayNames = append(displayNames, prtrs.Status.TaskSpec.DisplayName)
}
assert.DeepEqual(t, tt.displayNames, displayNames)
assert.ElementsMatch(t, tt.displayNames, displayNames)
}
if tt.expectedLogSnippet != "" {
logmsg := obslog.FilterMessageSnippet(tt.expectedLogSnippet).TakeAll()
assert.Assert(t, len(logmsg) > 0, "log messages", logmsg, tt.expectedLogSnippet)
assertv3.Assert(t, len(logmsg) > 0, "log messages", logmsg, tt.expectedLogSnippet)
}
})
}
Expand Down
27 changes: 27 additions & 0 deletions vendor/github.com/pmezard/go-difflib/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 021ec94

Please sign in to comment.