mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
alerts: refactoring tests
This commit is contained in:
parent
c5226a945b
commit
1f3442020b
@ -67,8 +67,7 @@ func TestAlertingDataAccess(t *testing.T) {
|
|||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
})
|
})
|
||||||
|
|
||||||
alert, err := getAlertById(1)
|
alert, _ := getAlertById(1)
|
||||||
So(err, ShouldBeNil)
|
|
||||||
stateDateBeforePause := alert.NewStateDate
|
stateDateBeforePause := alert.NewStateDate
|
||||||
|
|
||||||
Convey("can pause all alerts", func() {
|
Convey("can pause all alerts", func() {
|
||||||
@ -237,14 +236,6 @@ func TestAlertingDataAccess(t *testing.T) {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
func pauseAllAlerts(pauseState bool) error {
|
|
||||||
cmd := &m.PauseAllAlertCommand{
|
|
||||||
Paused: pauseState,
|
|
||||||
}
|
|
||||||
err := PauseAllAlerts(cmd)
|
|
||||||
So(err, ShouldBeNil)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPausingAlerts(t *testing.T) {
|
func TestPausingAlerts(t *testing.T) {
|
||||||
mockTimeNow()
|
mockTimeNow()
|
||||||
@ -262,8 +253,7 @@ func TestPausingAlerts(t *testing.T) {
|
|||||||
pauseAlert(testDash.OrgId, 1, true)
|
pauseAlert(testDash.OrgId, 1, true)
|
||||||
|
|
||||||
Convey("the NewStateDate should be updated", func() {
|
Convey("the NewStateDate should be updated", func() {
|
||||||
alert, err := getAlertById(1)
|
alert, _ := getAlertById(1)
|
||||||
So(err, ShouldBeNil)
|
|
||||||
|
|
||||||
stateDateAfterPause = alert.NewStateDate
|
stateDateAfterPause = alert.NewStateDate
|
||||||
So(stateDateBeforePause, ShouldHappenBefore, stateDateAfterPause)
|
So(stateDateBeforePause, ShouldHappenBefore, stateDateAfterPause)
|
||||||
@ -274,8 +264,7 @@ func TestPausingAlerts(t *testing.T) {
|
|||||||
pauseAlert(testDash.OrgId, 1, false)
|
pauseAlert(testDash.OrgId, 1, false)
|
||||||
|
|
||||||
Convey("the NewStateDate should be updated again", func() {
|
Convey("the NewStateDate should be updated again", func() {
|
||||||
alert, err := getAlertById(1)
|
alert, _ := getAlertById(1)
|
||||||
So(err, ShouldBeNil)
|
|
||||||
|
|
||||||
stateDateAfterUnpause := alert.NewStateDate
|
stateDateAfterUnpause := alert.NewStateDate
|
||||||
So(stateDateAfterPause, ShouldHappenBefore, stateDateAfterUnpause)
|
So(stateDateAfterPause, ShouldHappenBefore, stateDateAfterUnpause)
|
||||||
@ -325,3 +314,12 @@ func getAlertById(id int64) (*m.Alert, error) {
|
|||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
return q.Result, err
|
return q.Result, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func pauseAllAlerts(pauseState bool) error {
|
||||||
|
cmd := &m.PauseAllAlertCommand{
|
||||||
|
Paused: pauseState,
|
||||||
|
}
|
||||||
|
err := PauseAllAlerts(cmd)
|
||||||
|
So(err, ShouldBeNil)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user