From d7d904ae5fbeee881b28c1e5612e38c3bedfc943 Mon Sep 17 00:00:00 2001 From: Robert Hoppe Date: Wed, 17 Feb 2021 13:45:22 +0100 Subject: [PATCH] Bump up test coverage --- alerting/provider/custom/custom_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/alerting/provider/custom/custom_test.go b/alerting/provider/custom/custom_test.go index 8118fad8..5587255d 100644 --- a/alerting/provider/custom/custom_test.go +++ b/alerting/provider/custom/custom_test.go @@ -93,3 +93,24 @@ func TestAlertProvider_buildHTTPRequestWithCustomPlaceholder(t *testing.T) { t.Error("expected body to be", ExpectedBody, "was", string(body)) } } + +func TestAlertProvider_GetPlaceholderValue(t *testing.T) { + customAlertProvider := &AlertProvider{ + URL: "http://example.com/[SERVICE_NAME]?event=[ALERT_TRIGGERED_OR_RESOLVED]&description=[ALERT_DESCRIPTION]", + Body: "[SERVICE_NAME],[ALERT_DESCRIPTION],[ALERT_TRIGGERED_OR_RESOLVED]", + Headers: nil, + Placeholders: nil, + } + + if customAlertProvider.GetPlaceholderValue("I_DO_NOT_EXIST", "i_do_also_no_exist") != "" { + t.Error("expected empty response from a non existing placeholder") + } + + if customAlertProvider.GetPlaceholderValue("ALERT_TRIGGERED_OR_RESOLVED", "I_DO_NOT_EXIST") != "" { + t.Error("expected empty response from a non existing subvalue") + } + + if customAlertProvider.GetPlaceholderValue("ALERT_TRIGGERED_OR_RESOLVED", "triggered") != "TRIGGERED" { + t.Error("expected 'triggered' as a result") + } +}