Skip to content

Commit

Permalink
event-reporter / getConditionLevel: fixed wrong hadnling of error level
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandr-codefresh committed Oct 23, 2024
1 parent a31d298 commit e04a99d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion event_reporter/reporter/application_errors_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func getConditionLevel(cnd appv1.ApplicationCondition) string {
if cnd.IsWarning() {
return "warning"
}
if cnd.IsWarning() {
if cnd.IsError() {
return "error"
}
return ""
Expand Down
29 changes: 29 additions & 0 deletions event_reporter/reporter/applications_errors_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,35 @@ func TestParseResourceSyncResultErrors(t *testing.T) {
})
}

func TestGetConditionLevel(t *testing.T) {
errorsTypes := []v1alpha1.ApplicationCondition{
{Type: v1alpha1.ApplicationConditionDeletionError},
{Type: v1alpha1.ApplicationConditionInvalidSpecError},
{Type: v1alpha1.ApplicationConditionComparisonError},
{Type: v1alpha1.ApplicationConditionSyncError},
{Type: v1alpha1.ApplicationConditionUnknownError},
}
for _, errorAppCondition := range errorsTypes {
t.Run("parses as error "+errorAppCondition.Type, func(t *testing.T) {
level := getConditionLevel(errorAppCondition)
assert.Equal(t, "error", level)
})
}

warningTypes := []v1alpha1.ApplicationCondition{
{Type: v1alpha1.ApplicationConditionSharedResourceWarning},
{Type: v1alpha1.ApplicationConditionRepeatedResourceWarning},
{Type: v1alpha1.ApplicationConditionExcludedResourceWarning},
{Type: v1alpha1.ApplicationConditionOrphanedResourceWarning},
}
for _, warningAppCondition := range warningTypes {
t.Run("parses as warning "+warningAppCondition.Type, func(t *testing.T) {
level := getConditionLevel(warningAppCondition)
assert.Equal(t, "warning", level)
})
}
}

func TestParseApplicationSyncResultErrorsFromConditions(t *testing.T) {
t.Run("conditions exists", func(t *testing.T) {
errors := parseApplicationSyncResultErrorsFromConditions(v1alpha1.ApplicationStatus{
Expand Down

0 comments on commit e04a99d

Please sign in to comment.