Skip to content

Commit

Permalink
Fix disabled level of notication min severity (#495)
Browse files Browse the repository at this point in the history
Co-authored-by: Rouven Bauer <rouven.bauer@neo4j.com>
  • Loading branch information
fbiville and robsdedude authored May 24, 2023
1 parent 4f29cdc commit bbb6f6d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion neo4j/notifications/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type NotificationMinimumSeverityLevel string

const (
DefaultLevel NotificationMinimumSeverityLevel = ""
DisabledLevel NotificationMinimumSeverityLevel = "DISABLED"
DisabledLevel NotificationMinimumSeverityLevel = "OFF"
WarningLevel NotificationMinimumSeverityLevel = "WARNING"
InformationLevel NotificationMinimumSeverityLevel = "INFORMATION"
)
26 changes: 24 additions & 2 deletions testkit-backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,12 @@ func (b *backend) handleRequest(req map[string]any) {
c.SocketConnectTimeout = time.Millisecond * time.Duration(asInt64(data["connectionTimeoutMs"].(json.Number)))
}
if data["notificationsMinSeverity"] != nil {
c.NotificationsMinSeverity = notifications.NotificationMinimumSeverityLevel(data["notificationsMinSeverity"].(string))
minSeverity, err := mapNotificationMinSeverityLevel(data["notificationsMinSeverity"].(string))
if err != nil {
b.writeError(err)
return
}
c.NotificationsMinSeverity = minSeverity
}
if data["notificationsDisabledCategories"] != nil {
notiDisCats := data["notificationsDisabledCategories"].([]any)
Expand Down Expand Up @@ -644,7 +649,12 @@ func (b *backend) handleRequest(req map[string]any) {
}

if data["notificationsMinSeverity"] != nil {
sessionConfig.NotificationsMinSeverity = notifications.NotificationMinimumSeverityLevel(data["notificationsMinSeverity"].(string))
minSeverity, err := mapNotificationMinSeverityLevel(data["notificationsMinSeverity"].(string))
if err != nil {
b.writeError(err)
return
}
sessionConfig.NotificationsMinSeverity = minSeverity
}
if data["notificationsDisabledCategories"] != nil {
notiDisCats := data["notificationsDisabledCategories"].([]any)
Expand Down Expand Up @@ -1520,3 +1530,15 @@ func convertSlice[T any](slice []any, transform func(any) T) []T {
}
return res
}

func mapNotificationMinSeverityLevel(rawMinSeverityLevel string) (notifications.NotificationMinimumSeverityLevel, error) {
switch rawMinSeverityLevel {
case "OFF":
return notifications.DisabledLevel, nil
case "WARNING":
return notifications.WarningLevel, nil
case "INFORMATION":
return notifications.InformationLevel, nil
}
return "", fmt.Errorf("unknown min severity level %s", rawMinSeverityLevel)
}

0 comments on commit bbb6f6d

Please sign in to comment.