Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api/v1/common_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const (
ReasonBlocked = "Blocked"

// Deprecation reasons
ReasonDeprecated = "Deprecated"
ReasonDeprecated = "Deprecated"
ReasonNotDeprecated = "NotDeprecated"

// Common reasons
ReasonSucceeded = "Succeeded"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var ConditionTypes = []string{
var ConditionReasons = []string{
ocv1.ReasonSucceeded,
ocv1.ReasonDeprecated,
ocv1.ReasonNotDeprecated,
ocv1.ReasonFailed,
ocv1.ReasonBlocked,
ocv1.ReasonRetrying,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ import (
)

func TestClusterExtensionSourceConfig(t *testing.T) {
sourceTypeEmptyError := "Invalid value: null"
sourceTypeEmptyErrors := []string{"Invalid value: \"null\"", "Invalid value: null"}
sourceTypeMismatchError := "spec.source.sourceType: Unsupported value"
sourceConfigInvalidError := "spec.source: Invalid value"
// unionField represents the required Catalog or (future) Bundle field required by SourceConfig
testCases := []struct {
name string
sourceType string
unionField string
errMsg string
errMsgs []string
}{
{"sourceType is null", "", "Catalog", sourceTypeEmptyError},
{"sourceType is invalid", "Invalid", "Catalog", sourceTypeMismatchError},
{"catalog field does not exist", "Catalog", "", sourceConfigInvalidError},
{"sourceConfig has required fields", "Catalog", "Catalog", ""},
{"sourceType is null", "", "Catalog", sourceTypeEmptyErrors},
{"sourceType is invalid", "Invalid", "Catalog", []string{sourceTypeMismatchError}},
{"catalog field does not exist", "Catalog", "", []string{sourceConfigInvalidError}},
{"sourceConfig has required fields", "Catalog", "Catalog", nil},
}

t.Parallel()
Expand Down Expand Up @@ -62,12 +62,20 @@ func TestClusterExtensionSourceConfig(t *testing.T) {
}))
}

if tc.errMsg == "" {
if len(tc.errMsgs) == 0 {
require.NoError(t, err, "unexpected error for sourceType %q: %w", tc.sourceType, err)
} else {
require.Error(t, err)
require.Contains(t, err.Error(), tc.errMsg)
return
}

require.Error(t, err)
matched := false
for _, msg := range tc.errMsgs {
if strings.Contains(err.Error(), msg) {
matched = true
break
}
}
require.True(t, matched, "expected one of %v in error %q", tc.errMsgs, err)
})
}
}
Expand Down
Loading
Loading