From 20515b5dd4f161d0d04602fcfe7aa3810b90ea09 Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Wed, 21 Oct 2020 22:10:58 -0400 Subject: [PATCH] Improve test coverage --- config/config_test.go | 7 +++++++ core/service_test.go | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/config/config_test.go b/config/config_test.go index d8c1addb..2098ae48 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -298,3 +298,10 @@ func TestLoadFileThatDoesNotExist(t *testing.T) { 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") + } +} diff --git a/core/service_test.go b/core/service_test.go index 3758aac0..9a170e81 100644 --- a/core/service_test.go +++ b/core/service_test.go @@ -49,6 +49,7 @@ func TestService_ValidateAndSetDefaults(t *testing.T) { Name: "TwiNNatioN", Url: "https://twinnation.org/health", Conditions: []*Condition{&condition}, + Alerts: []*Alert{{Type: PagerDutyAlert}}, } service.ValidateAndSetDefaults() if service.Method != "GET" { @@ -60,4 +61,16 @@ func TestService_ValidateAndSetDefaults(t *testing.T) { if service.Headers == nil { 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") + } }