Alerting: take datasources as external alertmanagers into consideration (#52534)
This commit is contained in:
committed by
GitHub
parent
5c4aa4a7ac
commit
50ae42130b
@@ -84,7 +84,10 @@ func TestAdminConfiguration_SendingToExternalAlertmanagers(t *testing.T) {
|
||||
resp := postRequest(t, alertsURL, buf.String(), http.StatusBadRequest) // nolint
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
require.JSONEq(t, `{"message": "Invalid alertmanager choice specified"}`, string(b))
|
||||
var res map[string]interface{}
|
||||
err = json.Unmarshal(b, &res)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "Invalid alertmanager choice specified", res["message"])
|
||||
}
|
||||
|
||||
// Let's try to send all the alerts to an external Alertmanager
|
||||
@@ -102,7 +105,10 @@ func TestAdminConfiguration_SendingToExternalAlertmanagers(t *testing.T) {
|
||||
resp := postRequest(t, alertsURL, buf.String(), http.StatusBadRequest) // nolint
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
require.JSONEq(t, `{"message": "At least one Alertmanager must be provided to choose this option"}`, string(b))
|
||||
var res map[string]interface{}
|
||||
err = json.Unmarshal(b, &res)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "At least one Alertmanager must be provided or configured as a datasource that handles alerts to choose this option", res["message"])
|
||||
}
|
||||
|
||||
// Now, lets re-set external Alertmanagers for main organisation
|
||||
@@ -121,7 +127,10 @@ func TestAdminConfiguration_SendingToExternalAlertmanagers(t *testing.T) {
|
||||
resp := postRequest(t, alertsURL, buf.String(), http.StatusCreated) // nolint
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
require.JSONEq(t, `{"message": "admin configuration updated"}`, string(b))
|
||||
var res map[string]interface{}
|
||||
err = json.Unmarshal(b, &res)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "admin configuration updated", res["message"])
|
||||
}
|
||||
|
||||
// If we get the configuration again, it shows us what we've set.
|
||||
@@ -220,7 +229,10 @@ func TestAdminConfiguration_SendingToExternalAlertmanagers(t *testing.T) {
|
||||
resp := postRequest(t, alertsURL, buf.String(), http.StatusCreated) // nolint
|
||||
b, err := ioutil.ReadAll(resp.Body)
|
||||
require.NoError(t, err)
|
||||
require.JSONEq(t, "{\"message\": \"admin configuration updated\"}", string(b))
|
||||
var res map[string]interface{}
|
||||
err = json.Unmarshal(b, &res)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "admin configuration updated", res["message"])
|
||||
}
|
||||
|
||||
// If we get the configuration again, it shows us what we've set.
|
||||
|
||||
Reference in New Issue
Block a user