Skip to content

Commit

Permalink
Update TestRoutesTest
Browse files Browse the repository at this point in the history
Signed-off-by: George Robinson <george.robinson@grafana.com>
  • Loading branch information
grobinson-grafana committed Sep 14, 2023
1 parent 628b2c3 commit 50ed7e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/cli/acceptance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
5 changes: 5 additions & 0 deletions test/cli/acceptance/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

0 comments on commit 50ed7e1

Please sign in to comment.