feat(alerting): extracts alert rule reading

This commit is contained in:
bergquist
2016-05-30 18:52:38 +02:00
parent c5c261e955
commit 1498db11a9
9 changed files with 205 additions and 153 deletions
+4
View File
@@ -29,6 +29,10 @@ func SetNewAlertState(cmd *m.UpdateAlertStateCommand) error {
return err
}
//if alert.State == cmd.NewState {
// return nil
//}
alert.State = cmd.NewState
sess.Id(alert.Id).Update(&alert)
@@ -109,7 +109,7 @@ func TestAlertModel(t *testing.T) {
"critOperator": ">",
"aggregator": "sum",
"queryRange": "10m",
"interval": "10s",
"frequency": 10,
"title": "active desktop users",
"description": "restart webservers"
},
@@ -196,7 +196,7 @@ func TestAlertModel(t *testing.T) {
"critLevel": 500,
"aggregator": "avg",
"queryRange": "10m",
"interval": "10s",
"frequency": 10,
"title": "active mobile users",
"description": "restart itunes"
},
@@ -393,6 +393,9 @@ func TestAlertModel(t *testing.T) {
So(alerts[0].WarnLevel, ShouldEqual, 30)
So(alerts[1].WarnLevel, ShouldEqual, 300)
So(alerts[0].Frequency, ShouldEqual, 10)
So(alerts[1].Frequency, ShouldEqual, 10)
So(alerts[0].CritLevel, ShouldEqual, 50)
So(alerts[1].CritLevel, ShouldEqual, 500)