Add tests for "metrics" config property

This commit is contained in:
TwinProduction 2019-11-16 15:47:56 -05:00
parent e162740654
commit b08e563b2a

View File

@ -58,6 +58,32 @@ services:
if err != nil { if err != nil {
t.Error("No error should've been returned") t.Error("No error should've been returned")
} }
if config.Metrics {
t.Error("Metrics should've been false by default")
}
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[0].Interval != 10*time.Second {
t.Errorf("Interval should have been %s, because it is the default value", 10*time.Second)
}
}
func TestParseAndValidateConfigBytesWithMetrics(t *testing.T) {
config, err := parseAndValidateConfigBytes([]byte(`
metrics: true
services:
- name: twinnation
url: https://twinnation.org/actuator/health
conditions:
- "$STATUS == 200"
`))
if err != nil {
t.Error("No error should've been returned")
}
if !config.Metrics {
t.Error("Metrics should have been true")
}
if config.Services[0].Url != "https://twinnation.org/actuator/health" { if config.Services[0].Url != "https://twinnation.org/actuator/health" {
t.Errorf("URL should have been %s", "https://twinnation.org/actuator/health") t.Errorf("URL should have been %s", "https://twinnation.org/actuator/health")
} }