diff --git a/pkg/services/sqlstore/alert_notification.go b/pkg/services/sqlstore/alert_notification.go index 118fc4aca5b..1f37efca75f 100644 --- a/pkg/services/sqlstore/alert_notification.go +++ b/pkg/services/sqlstore/alert_notification.go @@ -112,7 +112,7 @@ func GetAlertNotificationsWithUid(query *models.GetAlertNotificationsWithUidQuer func GetAllAlertNotifications(query *models.GetAllAlertNotificationsQuery) error { results := make([]*models.AlertNotification, 0) - if err := x.Where("org_id = ?", query.OrgId).Find(&results); err != nil { + if err := x.Where("org_id = ?", query.OrgId).Asc("name").Find(&results); err != nil { return err } diff --git a/pkg/services/sqlstore/alert_notification_test.go b/pkg/services/sqlstore/alert_notification_test.go index 5b35416dcef..bde1ad2c4cf 100644 --- a/pkg/services/sqlstore/alert_notification_test.go +++ b/pkg/services/sqlstore/alert_notification_test.go @@ -325,6 +325,10 @@ func TestAlertNotificationSQLAccess(t *testing.T) { err := GetAllAlertNotifications(query) So(err, ShouldBeNil) So(len(query.Result), ShouldEqual, 4) + So(query.Result[0].Name, ShouldEqual, cmd4.Name) + So(query.Result[1].Name, ShouldEqual, cmd1.Name) + So(query.Result[2].Name, ShouldEqual, cmd3.Name) + So(query.Result[3].Name, ShouldEqual, cmd2.Name) }) })