mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 23:35:15 +08:00
Alerting API: send 404 not found error and enrich delete with UID endpoint response with alert notification ID (#27550)
* Alerting API: Send back 404 not found error for update and delete endpoints * Alerting API: send back alert notification id for delete with uid endpoint
This commit is contained in:
@ -390,5 +390,87 @@ func TestAlertNotificationSQLAccess(t *testing.T) {
|
||||
So(result, ShouldBeNil)
|
||||
})
|
||||
})
|
||||
|
||||
Convey("Cannot update non-existing Alert Notification", func() {
|
||||
updateCmd := &models.UpdateAlertNotificationCommand{
|
||||
Name: "NewName",
|
||||
Type: "webhook",
|
||||
OrgId: 1,
|
||||
SendReminder: true,
|
||||
DisableResolveMessage: true,
|
||||
Frequency: "60s",
|
||||
Settings: simplejson.New(),
|
||||
Id: 1,
|
||||
}
|
||||
err := UpdateAlertNotification(updateCmd)
|
||||
So(err, ShouldEqual, models.ErrAlertNotificationNotFound)
|
||||
|
||||
Convey("using UID", func() {
|
||||
updateWithUidCmd := &models.UpdateAlertNotificationWithUidCommand{
|
||||
Name: "NewName",
|
||||
Type: "webhook",
|
||||
OrgId: 1,
|
||||
SendReminder: true,
|
||||
DisableResolveMessage: true,
|
||||
Frequency: "60s",
|
||||
Settings: simplejson.New(),
|
||||
Uid: "uid",
|
||||
NewUid: "newUid",
|
||||
}
|
||||
err := UpdateAlertNotificationWithUid(updateWithUidCmd)
|
||||
So(err, ShouldEqual, models.ErrAlertNotificationNotFound)
|
||||
})
|
||||
})
|
||||
|
||||
Convey("Can delete Alert Notification", func() {
|
||||
cmd := &models.CreateAlertNotificationCommand{
|
||||
Name: "ops update",
|
||||
Type: "email",
|
||||
OrgId: 1,
|
||||
SendReminder: false,
|
||||
Settings: simplejson.New(),
|
||||
}
|
||||
|
||||
err := CreateAlertNotificationCommand(cmd)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
deleteCmd := &models.DeleteAlertNotificationCommand{
|
||||
Id: cmd.Result.Id,
|
||||
OrgId: 1,
|
||||
}
|
||||
err = DeleteAlertNotification(deleteCmd)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
Convey("using UID", func() {
|
||||
err := CreateAlertNotificationCommand(cmd)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
deleteWithUidCmd := &models.DeleteAlertNotificationWithUidCommand{
|
||||
Uid: cmd.Result.Uid,
|
||||
OrgId: 1,
|
||||
}
|
||||
err = DeleteAlertNotificationWithUid(deleteWithUidCmd)
|
||||
So(err, ShouldBeNil)
|
||||
So(deleteWithUidCmd.DeletedAlertNotificationId, ShouldEqual, cmd.Result.Id)
|
||||
})
|
||||
})
|
||||
|
||||
Convey("Cannot delete non-existing Alert Notification", func() {
|
||||
deleteCmd := &models.DeleteAlertNotificationCommand{
|
||||
Id: 1,
|
||||
OrgId: 1,
|
||||
}
|
||||
err := DeleteAlertNotification(deleteCmd)
|
||||
So(err, ShouldEqual, models.ErrAlertNotificationNotFound)
|
||||
|
||||
Convey("using UID", func() {
|
||||
deleteWithUidCmd := &models.DeleteAlertNotificationWithUidCommand{
|
||||
Uid: "uid",
|
||||
OrgId: 1,
|
||||
}
|
||||
err = DeleteAlertNotificationWithUid(deleteWithUidCmd)
|
||||
So(err, ShouldEqual, models.ErrAlertNotificationNotFound)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user