Skip to content

Commit a00ab1c

Browse files
committed
Fix flaky unit-test spec for Build
We assert for a combination of secret names under Status.Message when the secrets validation fails. Because the list of secrets comes from a map and a map is an unordered collection of key-value pairs, this commits adds a sort, to ensure an ordered list in Status.Message and for avoiding the flakiness in the unit-test spec.
1 parent c0bfa60 commit a00ab1c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pkg/validate/secrets.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package validate
33
import (
44
"context"
55
"fmt"
6+
"sort"
67
"strings"
78

89
build "github.com/shipwright-io/build/pkg/apis/build/v1alpha1"
@@ -37,6 +38,9 @@ func (s SecretRef) ValidatePath(ctx context.Context) error {
3738
}
3839
}
3940

41+
// sorts a list of secret names in increasing order
42+
sort.Strings(missingSecrets)
43+
4044
if len(missingSecrets) > 1 {
4145
s.Build.Status.Reason = build.MultipleSecretRefNotFound
4246
s.Build.Status.Message = fmt.Sprintf("missing secrets are %s", strings.Join(missingSecrets, ","))

0 commit comments

Comments
 (0)