fix(alerting): Adjust minimum reminder config parsing (#1226)

* Update minimum repeat interval parsing

* Update minimum repeat interval parsing
This commit is contained in:
Sean Kelly
2025-08-25 20:31:23 -07:00
committed by GitHub
parent a49b9145d2
commit d41cfc0d16
2 changed files with 9 additions and 0 deletions

View File

@@ -84,6 +84,9 @@ func MergeProviderDefaultAlertIntoEndpointAlert(providerDefaultAlert, endpointAl
if endpointAlert.SuccessThreshold == 0 { if endpointAlert.SuccessThreshold == 0 {
endpointAlert.SuccessThreshold = providerDefaultAlert.SuccessThreshold endpointAlert.SuccessThreshold = providerDefaultAlert.SuccessThreshold
} }
if endpointAlert.MinimumReminderInterval == 0 {
endpointAlert.MinimumReminderInterval = providerDefaultAlert.MinimumReminderInterval
}
} }
var ( var (

View File

@@ -2,6 +2,7 @@ package provider
import ( import (
"testing" "testing"
"time"
"github.com/TwiN/gatus/v5/alerting/alert" "github.com/TwiN/gatus/v5/alerting/alert"
) )
@@ -24,6 +25,7 @@ func TestParseWithDefaultAlert(t *testing.T) {
Description: &firstDescription, Description: &firstDescription,
FailureThreshold: 5, FailureThreshold: 5,
SuccessThreshold: 10, SuccessThreshold: 10,
MinimumReminderInterval: 30 * time.Second,
}, },
EndpointAlert: &alert.Alert{ EndpointAlert: &alert.Alert{
Type: alert.TypeDiscord, Type: alert.TypeDiscord,
@@ -35,6 +37,7 @@ func TestParseWithDefaultAlert(t *testing.T) {
Description: &firstDescription, Description: &firstDescription,
FailureThreshold: 5, FailureThreshold: 5,
SuccessThreshold: 10, SuccessThreshold: 10,
MinimumReminderInterval: 30 * time.Second,
}, },
}, },
{ {
@@ -148,6 +151,9 @@ func TestParseWithDefaultAlert(t *testing.T) {
if scenario.EndpointAlert.SuccessThreshold != scenario.ExpectedOutputAlert.SuccessThreshold { if scenario.EndpointAlert.SuccessThreshold != scenario.ExpectedOutputAlert.SuccessThreshold {
t.Errorf("expected EndpointAlert.SuccessThreshold to be %v, got %v", scenario.ExpectedOutputAlert.SuccessThreshold, scenario.EndpointAlert.SuccessThreshold) t.Errorf("expected EndpointAlert.SuccessThreshold to be %v, got %v", scenario.ExpectedOutputAlert.SuccessThreshold, scenario.EndpointAlert.SuccessThreshold)
} }
if int(scenario.EndpointAlert.MinimumReminderInterval) != int(scenario.ExpectedOutputAlert.MinimumReminderInterval) {
t.Errorf("expected EndpointAlert.MinimumReminderInterval to be %v, got %v", scenario.ExpectedOutputAlert.MinimumReminderInterval, scenario.EndpointAlert.MinimumReminderInterval)
}
}) })
} }
} }