From 50ed7e1239f527ca766531fc6bfbae3320810e41 Mon Sep 17 00:00:00 2001 From: George Robinson Date: Wed, 13 Sep 2023 21:04:17 +0100 Subject: [PATCH] Update TestRoutesTest Signed-off-by: George Robinson --- test/cli/acceptance.go | 8 ++++---- test/cli/acceptance/cli_test.go | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/test/cli/acceptance.go b/test/cli/acceptance.go index 8866773b67..68554ec714 100644 --- a/test/cli/acceptance.go +++ b/test/cli/acceptance.go @@ -683,13 +683,13 @@ func (am *Alertmanager) showRouteCommand() ([]byte, error) { return cmd.CombinedOutput() } -func (am *Alertmanager) TestRoute() ([]byte, error) { - return am.testRouteCommand() +func (am *Alertmanager) TestRoute(labels ...string) ([]byte, error) { + return am.testRouteCommand(labels...) } -func (am *Alertmanager) testRouteCommand() ([]byte, error) { +func (am *Alertmanager) testRouteCommand(labels ...string) ([]byte, error) { amURLFlag := "--alertmanager.url=" + am.getURL("/") - args := []string{amURLFlag, "config", "routes", "test"} + args := append([]string{amURLFlag, "config", "routes", "test"}, labels...) cmd := exec.Command(amtool, args...) return cmd.CombinedOutput() } diff --git a/test/cli/acceptance/cli_test.go b/test/cli/acceptance/cli_test.go index 28b2e387c5..bc6af58599 100644 --- a/test/cli/acceptance/cli_test.go +++ b/test/cli/acceptance/cli_test.go @@ -265,4 +265,9 @@ receivers: am := amc.Members()[0] _, err := am.TestRoute() require.NoError(t, err) + + // Bad labels should return error + out, err := am.TestRoute("{foo=bar}") + require.EqualError(t, err, "exit status 1") + require.Equal(t, "amtool: error: Failed to parse labels: bad matcher format: {foo=bar}\n\n", string(out)) }