require.JSONEq(t,`{"message": "failed to save and apply Alertmanager configuration: failed to build integration map: the receiver is invalid: failed to validate receiver \"slack.receiver\" of type \"slack\": token must be specified when using the Slack chat API","error":"failed to save and apply Alertmanager configuration: failed to build integration map: the receiver is invalid: failed to validate receiver \"slack.receiver\" of type \"slack\": token must be specified when using the Slack chat API"}`,getBody(t,resp.Body))
require.JSONEq(t,`{"message": "failed to save and apply Alertmanager configuration: failed to build integration map: the receiver is invalid: failed to validate receiver \"slack.receiver\" of type \"slack\": token must be specified when using the Slack chat API"}`,getBody(t,resp.Body))
expectedResponse:`{"message": "user does not have permissions to edit the namespace: user does not have permissions to edit the namespace","error":"user does not have permissions to edit the namespace: user does not have permissions to edit the namespace"}`,
expectedResponse:`{"message": "user does not have permissions to edit the namespace: user does not have permissions to edit the namespace"}`,
expectedResponse:`{"message": "failed to update rule group: invalid alert rule: no queries or expressions are found","error":"failed to update rule group: invalid alert rule: no queries or expressions are found"}`,
expectedResponse:`{"message": "failed to update rule group: invalid alert rule: no queries or expressions are found"}`,
expectedResponse:`{"message": "failed to update rule group: invalid alert rule: title is empty","error":"failed to update rule group: invalid alert rule: title is empty"}`,
expectedResponse:`{"message": "failed to update rule group: invalid alert rule: title is empty"}`,
expectedResponse:`{"message": "failed to update rule group: invalid alert rule: name length should not be greater than 190","error":"failed to update rule group: invalid alert rule: name length should not be greater than 190"}`,
expectedResponse:`{"message": "failed to update rule group: invalid alert rule: name length should not be greater than 190"}`,
expectedResponse:`{"message": "failed to update rule group: invalid alert rule: rule group name length should not be greater than 190","error":"failed to update rule group: invalid alert rule: rule group name length should not be greater than 190"}`,
expectedResponse:`{"message": "failed to update rule group: invalid alert rule: rule group name length should not be greater than 190"}`,
expectedResponse:`{"message": "failed to update rule group: invalid alert rule: interval (1s) should be non-zero and divided exactly by scheduler interval: 10s","error":"failed to update rule group: invalid alert rule: interval (1s) should be non-zero and divided exactly by scheduler interval: 10s"}`,
expectedResponse:`{"message": "failed to update rule group: invalid alert rule: interval (1s) should be non-zero and divided exactly by scheduler interval: 10s"}`,
expectedResponse:`{"message": "failed to validate alert rule \"AlwaysFiring\": invalid query A: data source not found: unknown","error":"failed to validate alert rule \"AlwaysFiring\": invalid query A: data source not found: unknown"}`,
expectedResponse:`{"message": "failed to validate alert rule \"AlwaysFiring\": invalid query A: data source not found: unknown"}`,
expectedResponse:`{"message": "failed to validate alert rule \"AlwaysFiring\": condition B not found in any query or expression: it should be one of: [A]","error":"failed to validate alert rule \"AlwaysFiring\": condition B not found in any query or expression: it should be one of: [A]"}`,
expectedResponse:`{"message": "failed to validate alert rule \"AlwaysFiring\": condition B not found in any query or expression: it should be one of: [A]"}`,
require.JSONEq(t,`{"message": "failed to update rule group: failed to get alert rule unknown: could not find alert rule","error":"failed to update rule group: failed to get alert rule unknown: could not find alert rule"}`,string(b))
require.JSONEq(t,`{"message": "failed to update rule group: failed to get alert rule unknown: could not find alert rule"}`,string(b))
// let's make sure that rule definitions are not affected by the failed POST request.
require.JSONEq(t,`{"message": "failed to delete rule group: rule group not found under this namespace","error":"failed to delete rule group: rule group not found under this namespace"}`,string(b))
require.JSONEq(t,`{"message": "failed to delete rule group: rule group not found under this namespace"}`,string(b))
})
t.Run("succeed if the rule group name does exist",func(t*testing.T){
expectedResponse:`{"message": "invalid condition: condition B not found in any query or expression: it should be one of: [A]","error":"invalid condition: condition B not found in any query or expression: it should be one of: [A]"}`,
expectedResponse:`{"message": "invalid condition: condition B not found in any query or expression: it should be one of: [A]"}`,
expectedResponse:`{"message": "invalid condition: invalid query A: data source not found: unknown","error":"invalid condition: invalid query A: data source not found: unknown"}`,
expectedResponse:`{"message": "invalid condition: invalid query A: data source not found: unknown"}`,
expectedResponse:`{"message": "invalid queries or expressions: invalid query A: data source not found: unknown","error":"invalid queries or expressions: invalid query A: data source not found: unknown"}`,
expectedResponse:`{"message": "invalid queries or expressions: invalid query A: data source not found: unknown"}`,
require.JSONEq(t,`{"message": "failed to update rule group: invalid alert rule: cannot have Panel ID without a Dashboard UID","error":"failed to update rule group: invalid alert rule: cannot have Panel ID without a Dashboard UID"}`,string(b))
require.JSONEq(t,`{"message": "failed to update rule group: invalid alert rule: cannot have Panel ID without a Dashboard UID"}`,string(b))
require.JSONEq(t,`{"message": "failed to update rule group: a conflicting alert rule is found: rule title under the same organisation and folder should be unique","error":"failed to update rule group: a conflicting alert rule is found: rule title under the same organisation and folder should be unique"}`,string(b))
require.JSONEq(t,`{"message": "failed to update rule group: a conflicting alert rule is found: rule title under the same organisation and folder should be unique"}`,string(b))
})
t.Run("trying to create alert with same title under another folder should succeed",func(t*testing.T){