mirror of
https://github.com/TwiN/gatus.git
synced 2024-11-22 16:03:44 +01:00
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package ntfy
|
|
|
|
import "testing"
|
|
|
|
func TestAlertDefaultProvider_IsValid(t *testing.T) {
|
|
scenarios := []struct {
|
|
name string
|
|
provider AlertProvider
|
|
expected bool
|
|
}{
|
|
{
|
|
name: "valid",
|
|
provider: AlertProvider{URL: "https://ntfy.sh", Topic: "example", Priority: 1},
|
|
expected: true,
|
|
},
|
|
{
|
|
name: "no-url-should-use-default-value",
|
|
provider: AlertProvider{Topic: "example", Priority: 1},
|
|
expected: true,
|
|
},
|
|
{
|
|
name: "invalid-topic",
|
|
provider: AlertProvider{URL: "https://ntfy.sh", Topic: "", Priority: 1},
|
|
expected: false,
|
|
},
|
|
{
|
|
name: "invalid-priority-too-high",
|
|
provider: AlertProvider{URL: "https://ntfy.sh", Topic: "example", Priority: 6},
|
|
expected: false,
|
|
},
|
|
{
|
|
name: "invalid-priority-too-low",
|
|
provider: AlertProvider{URL: "https://ntfy.sh", Topic: "example", Priority: -1},
|
|
expected: false,
|
|
},
|
|
{
|
|
name: "no-priority-should-use-default-value",
|
|
provider: AlertProvider{URL: "https://ntfy.sh", Topic: "example"},
|
|
expected: true,
|
|
},
|
|
}
|
|
for _, scenario := range scenarios {
|
|
t.Run(scenario.name, func(t *testing.T) {
|
|
if scenario.provider.IsValid() != scenario.expected {
|
|
t.Errorf("expected %t, got %t", scenario.expected, scenario.provider.IsValid())
|
|
}
|
|
})
|
|
}
|
|
}
|