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)) }