test(alerting): Improve coverage for custom alerting provider

This commit is contained in:
TwiN 2022-09-07 18:19:20 -04:00
parent d9f86f1155
commit 46d6d6c733

View File

@ -13,14 +13,24 @@ import (
) )
func TestAlertProvider_IsValid(t *testing.T) { func TestAlertProvider_IsValid(t *testing.T) {
invalidProvider := AlertProvider{URL: ""} t.Run("invalid-provider", func(t *testing.T) {
if invalidProvider.IsValid() { invalidProvider := AlertProvider{URL: ""}
t.Error("provider shouldn't have been valid") if invalidProvider.IsValid() {
} t.Error("provider shouldn't have been valid")
validProvider := AlertProvider{URL: "https://example.com"} }
if !validProvider.IsValid() { })
t.Error("provider should've been valid") t.Run("valid-provider", func(t *testing.T) {
} validProvider := AlertProvider{URL: "https://example.com"}
if validProvider.ClientConfig != nil {
t.Error("provider client config should have been nil prior to IsValid() being executed")
}
if !validProvider.IsValid() {
t.Error("provider should've been valid")
}
if validProvider.ClientConfig == nil {
t.Error("provider client config should have been set after IsValid() was executed")
}
})
} }
func TestAlertProvider_Send(t *testing.T) { func TestAlertProvider_Send(t *testing.T) {