(t *testing.T)
| 263 | } |
| 264 | |
| 265 | func Test_ValidateAlertmanagerConfig(t *testing.T) { |
| 266 | setup(t) |
| 267 | defer cleanup(t) |
| 268 | |
| 269 | userID := makeUserID() |
| 270 | for i, test := range amCfgValidationTests { |
| 271 | resp := requestAsUser(t, userID, "POST", "/api/prom/configs/alertmanager/validate", "", strings.NewReader(test.config)) |
| 272 | data := map[string]string{} |
| 273 | err := json.Unmarshal(resp.Body.Bytes(), &data) |
| 274 | assert.NoError(t, err, "test case %d", i) |
| 275 | |
| 276 | success := map[string]string{ |
| 277 | "status": "success", |
| 278 | } |
| 279 | if !test.shouldFail { |
| 280 | assert.Equal(t, success, data, "test case %d", i) |
| 281 | assert.Equal(t, http.StatusOK, resp.Code, "test case %d", i) |
| 282 | continue |
| 283 | } |
| 284 | |
| 285 | assert.Equal(t, "error", data["status"], "test case %d", i) |
| 286 | assert.Contains(t, data["error"], test.errContains, "test case %d", i) |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | func Test_SetConfig_ValidatesAlertmanagerConfig(t *testing.T) { |
| 291 | setup(t) |
nothing calls this directly
no test coverage detected