1
0
Fork 0
mirror of https://github.com/TwiN/gatus.git synced 2024-12-14 11:58:04 +00:00
twin-gatus/config/config_test.go

48 lines
1.4 KiB
Go
Raw Normal View History

2019-09-06 04:02:00 +00:00
package config
import "testing"
func TestParseConfigBytes(t *testing.T) {
config := ParseConfigBytes([]byte(`
services:
- name: twinnation
url: https://twinnation.org/actuator/health
2019-09-07 00:25:31 +00:00
interval: 15
2019-09-06 04:02:00 +00:00
failure-threshold: 3
conditions:
- "$STATUS == 200"
- name: github
url: https://github.com
conditions:
2019-09-07 00:25:31 +00:00
- "$STATUS != 400"
2019-09-06 04:02:00 +00:00
- "$STATUS != 500"
`))
if len(config.Services) != 2 {
t.Error("Should have returned two services")
}
if config.Services[0].Url != "https://twinnation.org/actuator/health" {
t.Errorf("URL should have been %s", "https://twinnation.org/actuator/health")
}
if config.Services[1].Url != "https://github.com" {
t.Errorf("URL should have been %s", "https://github.com")
}
2019-09-07 00:25:31 +00:00
if config.Services[0].Interval != 15 {
t.Errorf("Interval should have been %d", 15)
2019-09-06 04:02:00 +00:00
}
2019-09-07 00:25:31 +00:00
if config.Services[1].Interval != 10 {
t.Errorf("Interval should have been %d, because it is the default value", 10)
2019-09-06 04:02:00 +00:00
}
if config.Services[0].FailureThreshold != 3 {
t.Errorf("FailureThreshold should have been %d", 3)
}
2019-09-07 00:25:31 +00:00
if config.Services[1].FailureThreshold != 1 {
t.Errorf("FailureThreshold should have been %d, because it is the default value", 1)
2019-09-06 04:02:00 +00:00
}
if len(config.Services[0].Conditions) != 1 {
t.Errorf("There should have been %d conditions", 1)
}
if len(config.Services[1].Conditions) != 2 {
t.Errorf("There should have been %d conditions", 2)
}
}