MCPcopy Create free account
hub / github.com/cortexproject/cortex / Test_ValidateAlertmanagerConfig

Function Test_ValidateAlertmanagerConfig

pkg/configs/api/api_test.go:265–288  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

263}
264
265func 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
290func Test_SetConfig_ValidatesAlertmanagerConfig(t *testing.T) {
291 setup(t)

Callers

nothing calls this directly

Calls 7

setupFunction · 0.85
cleanupFunction · 0.85
makeUserIDFunction · 0.85
requestAsUserFunction · 0.85
BytesMethod · 0.65
EqualMethod · 0.65
UnmarshalMethod · 0.45

Tested by

no test coverage detected