tech(alerting): expression -> settings
This commit is contained in:
+4
-4
@@ -20,7 +20,7 @@ type Alert struct {
|
||||
Created time.Time
|
||||
Updated time.Time
|
||||
|
||||
Expression *simplejson.Json
|
||||
Settings *simplejson.Json
|
||||
}
|
||||
|
||||
func (alert *Alert) ValidToSave() bool {
|
||||
@@ -32,9 +32,9 @@ func (this *Alert) ContainsUpdates(other *Alert) bool {
|
||||
result = result || this.Name != other.Name
|
||||
result = result || this.Description != other.Description
|
||||
|
||||
if this.Expression != nil && other.Expression != nil {
|
||||
json1, err1 := this.Expression.Encode()
|
||||
json2, err2 := other.Expression.Encode()
|
||||
if this.Settings != nil && other.Settings != nil {
|
||||
json1, err1 := this.Settings.Encode()
|
||||
json2, err2 := other.Settings.Encode()
|
||||
|
||||
if err1 != nil || err2 != nil {
|
||||
return false
|
||||
|
||||
@@ -14,13 +14,13 @@ func TestAlertingModelTest(t *testing.T) {
|
||||
json2, _ := simplejson.NewJson([]byte(`{ "field": "value" }`))
|
||||
|
||||
rule1 := &Alert{
|
||||
Expression: json1,
|
||||
Settings: json1,
|
||||
Name: "Namn",
|
||||
Description: "Description",
|
||||
}
|
||||
|
||||
rule2 := &Alert{
|
||||
Expression: json2,
|
||||
Settings: json2,
|
||||
Name: "Namn",
|
||||
Description: "Description",
|
||||
}
|
||||
@@ -32,7 +32,7 @@ func TestAlertingModelTest(t *testing.T) {
|
||||
|
||||
Convey("Changing the expression should contain update", func() {
|
||||
json2, _ := simplejson.NewJson([]byte(`{ "field": "newValue" }`))
|
||||
rule1.Expression = json2
|
||||
rule1.Settings = json2
|
||||
So(rule1.ContainsUpdates(rule2), ShouldBeTrue)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user