mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
alert: add missing test after refactor
This commit is contained in:
parent
92d417f6b4
commit
f5cc7618c5
@ -13,7 +13,7 @@ func mockTimeNow() {
|
|||||||
var timeSeed int64
|
var timeSeed int64
|
||||||
timeNow = func() time.Time {
|
timeNow = func() time.Time {
|
||||||
fakeNow := time.Unix(timeSeed, 0)
|
fakeNow := time.Unix(timeSeed, 0)
|
||||||
timeSeed += 1
|
timeSeed++
|
||||||
return fakeNow
|
return fakeNow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ func TestAlertingDataAccess(t *testing.T) {
|
|||||||
InitTestDB(t)
|
InitTestDB(t)
|
||||||
|
|
||||||
testDash := insertTestDashboard("dashboard with alerts", 1, 0, false, "alert")
|
testDash := insertTestDashboard("dashboard with alerts", 1, 0, false, "alert")
|
||||||
|
evalData, _ := simplejson.NewJson([]byte(`{"test": "test"}`))
|
||||||
items := []*m.Alert{
|
items := []*m.Alert{
|
||||||
{
|
{
|
||||||
PanelId: 1,
|
PanelId: 1,
|
||||||
@ -40,6 +40,7 @@ func TestAlertingDataAccess(t *testing.T) {
|
|||||||
Message: "Alerting message",
|
Message: "Alerting message",
|
||||||
Settings: simplejson.New(),
|
Settings: simplejson.New(),
|
||||||
Frequency: 1,
|
Frequency: 1,
|
||||||
|
EvalData: evalData,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,8 +105,18 @@ func TestAlertingDataAccess(t *testing.T) {
|
|||||||
|
|
||||||
alert := alertQuery.Result[0]
|
alert := alertQuery.Result[0]
|
||||||
So(err2, ShouldBeNil)
|
So(err2, ShouldBeNil)
|
||||||
|
So(alert.Id, ShouldBeGreaterThan, 0)
|
||||||
|
So(alert.DashboardId, ShouldEqual, testDash.Id)
|
||||||
|
So(alert.PanelId, ShouldEqual, 1)
|
||||||
So(alert.Name, ShouldEqual, "Alerting title")
|
So(alert.Name, ShouldEqual, "Alerting title")
|
||||||
So(alert.State, ShouldEqual, "pending")
|
So(alert.State, ShouldEqual, "pending")
|
||||||
|
So(alert.NewStateDate, ShouldNotBeNil)
|
||||||
|
So(alert.EvalData, ShouldNotBeNil)
|
||||||
|
So(alert.EvalData.Get("test").MustString(), ShouldEqual, "test")
|
||||||
|
So(alert.EvalDate, ShouldNotBeNil)
|
||||||
|
So(alert.ExecutionError, ShouldEqual, "")
|
||||||
|
So(alert.DashboardUid, ShouldNotBeNil)
|
||||||
|
So(alert.DashboardSlug, ShouldEqual, "dashboard-with-alerts")
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("Viewer cannot read alerts", func() {
|
Convey("Viewer cannot read alerts", func() {
|
||||||
|
Loading…
Reference in New Issue
Block a user