mirror of
https://github.com/TwiN/gatus.git
synced 2025-01-09 23:48:21 +01:00
Improve test coverage
This commit is contained in:
parent
7dc200d887
commit
20515b5dd4
@ -298,3 +298,10 @@ func TestLoadFileThatDoesNotExist(t *testing.T) {
|
|||||||
t.Error("Should've returned an error, because the file specified doesn't exist")
|
t.Error("Should've returned an error, because the file specified doesn't exist")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLoadDefaultConfigurationFile(t *testing.T) {
|
||||||
|
err := LoadDefaultConfiguration()
|
||||||
|
if err == nil {
|
||||||
|
t.Error("Should've returned an error, because there's no configuration files at the default path nor the default fallback path")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -49,6 +49,7 @@ func TestService_ValidateAndSetDefaults(t *testing.T) {
|
|||||||
Name: "TwiNNatioN",
|
Name: "TwiNNatioN",
|
||||||
Url: "https://twinnation.org/health",
|
Url: "https://twinnation.org/health",
|
||||||
Conditions: []*Condition{&condition},
|
Conditions: []*Condition{&condition},
|
||||||
|
Alerts: []*Alert{{Type: PagerDutyAlert}},
|
||||||
}
|
}
|
||||||
service.ValidateAndSetDefaults()
|
service.ValidateAndSetDefaults()
|
||||||
if service.Method != "GET" {
|
if service.Method != "GET" {
|
||||||
@ -60,4 +61,16 @@ func TestService_ValidateAndSetDefaults(t *testing.T) {
|
|||||||
if service.Headers == nil {
|
if service.Headers == nil {
|
||||||
t.Error("Service headers should've defaulted to an empty map")
|
t.Error("Service headers should've defaulted to an empty map")
|
||||||
}
|
}
|
||||||
|
if len(service.Alerts) != 1 {
|
||||||
|
t.Error("Service should've had 1 alert")
|
||||||
|
}
|
||||||
|
if service.Alerts[0].Enabled {
|
||||||
|
t.Error("Service alert should've defaulted to disabled")
|
||||||
|
}
|
||||||
|
if service.Alerts[0].SuccessThreshold != 2 {
|
||||||
|
t.Error("Service alert should've defaulted to a success threshold of 2")
|
||||||
|
}
|
||||||
|
if service.Alerts[0].FailureThreshold != 3 {
|
||||||
|
t.Error("Service alert should've defaulted to a failure threshold of 3")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user