Commit f5809c02 by Torkel Ödegaard

fix(build): trying to fix build

parent 9cd51778
package notifiers package notifiers
import . "github.com/smartystreets/goconvey/convey" // import . "github.com/smartystreets/goconvey/convey"
//
func TestBaseNotifier( /* t *testing.T */ ) { // func TestBaseNotifier( t *testing.T ) {
// Convey("Parsing base notification state", t, func() { // Convey("Parsing base notification state", t, func() {
// //
// Convey("matches", func() { // Convey("matches", func() {
// json := ` // json := `
// { // {
// "states": "critical" // "states": "critical"
// }` // }`
// //
// settingsJSON, _ := simplejson.NewJson([]byte(json)) // settingsJSON, _ := simplejson.NewJson([]byte(json))
// not := NewNotifierBase("ops", "email", settingsJSON) // not := NewNotifierBase("ops", "email", settingsJSON)
// So(not.MatchSeverity(m.AlertSeverityCritical), ShouldBeTrue) // So(not.MatchSeverity(m.AlertSeverityCritical), ShouldBeTrue)
// }) // })
// //
// Convey("does not match", func() { // Convey("does not match", func() {
// json := ` // json := `
// { // {
// "severityFilter": "critical" // "severityFilter": "critical"
// }` // }`
// //
// settingsJSON, _ := simplejson.NewJson([]byte(json)) // settingsJSON, _ := simplejson.NewJson([]byte(json))
// not := NewNotifierBase("ops", "email", settingsJSON) // not := NewNotifierBase("ops", "email", settingsJSON)
// So(not.MatchSeverity(m.AlertSeverityWarning), ShouldBeFalse) // So(not.MatchSeverity(m.AlertSeverityWarning), ShouldBeFalse)
// }) // })
// }) // })
} // }
...@@ -35,38 +35,34 @@ func handleNotificationTestCommand(cmd *NotificationTestCommand) error { ...@@ -35,38 +35,34 @@ func handleNotificationTestCommand(cmd *NotificationTestCommand) error {
return err return err
} }
notifier.sendNotifications([]Notifier{notifiers}, createTestEvalContext(cmd.State)) notifier.sendNotifications([]Notifier{notifiers}, createTestEvalContext())
return nil return nil
} }
func createTestEvalContext(state m.AlertStateType) *EvalContext { func createTestEvalContext() *EvalContext {
testRule := &Rule{ testRule := &Rule{
DashboardId: 1, DashboardId: 1,
PanelId: 1, PanelId: 1,
Name: "Test notification", Name: "Test notification",
Message: "Someone is testing the alert notification within grafana.", Message: "Someone is testing the alert notification within grafana.",
State: state, State: m.AlertStateAlerting,
} }
ctx := NewEvalContext(testRule) ctx := NewEvalContext(testRule)
ctx.ImagePublicUrl = "http://grafana.org/assets/img/blog/mixed_styles.png" ctx.ImagePublicUrl = "http://grafana.org/assets/img/blog/mixed_styles.png"
ctx.IsTestRun = true ctx.IsTestRun = true
ctx.Firing = state == m.AlertStateAlerting ctx.Firing = true
ctx.Error = nil ctx.Error = nil
ctx.EvalMatches = evalMatchesBasedOnState(state) ctx.EvalMatches = evalMatchesBasedOnState()
return ctx return ctx
} }
func evalMatchesBasedOnState(state m.AlertStateType) []*EvalMatch { func evalMatchesBasedOnState() []*EvalMatch {
matches := make([]*EvalMatch, 0) matches := make([]*EvalMatch, 0)
if state == m.AlertStateOK {
return matches
}
matches = append(matches, &EvalMatch{ matches = append(matches, &EvalMatch{
Metric: "High value", Metric: "High value",
Value: 100, Value: 100,
......
...@@ -62,7 +62,6 @@ export class AlertNotificationEditCtrl { ...@@ -62,7 +62,6 @@ export class AlertNotificationEditCtrl {
name: this.model.name, name: this.model.name,
type: this.model.type, type: this.model.type,
settings: this.model.settings, settings: this.model.settings,
severity: this.testSeverity
}; };
this.backendSrv.post(`/api/alert-notifications/test`, payload) this.backendSrv.post(`/api/alert-notifications/test`, payload)
......
...@@ -26,15 +26,6 @@ ...@@ -26,15 +26,6 @@
</div> </div>
</div> </div>
<div class="gf-form"> <div class="gf-form">
<span class="gf-form-label width-12">Severity filter</span>
<div class="gf-form-select-wrapper width-15">
<select class="gf-form-input"
ng-model="ctrl.model.settings.severityFilter"
ng-options="t for t in ['none', 'critical', 'warning']">
</select>
</div>
</div>
<div class="gf-form">
<gf-form-switch <gf-form-switch
class="gf-form" class="gf-form"
label="Send on all alerts" label="Send on all alerts"
...@@ -86,16 +77,7 @@ ...@@ -86,16 +77,7 @@
<div class="gf-form width-8"> <div class="gf-form width-8">
<button ng-click="ctrl.toggleTest()" class="btn btn-secondary">Test</button> <button ng-click="ctrl.toggleTest()" class="btn btn-secondary">Test</button>
</div> </div>
<div class="gf-form width-20" ng-show="ctrl.showTest"> <div class="gf-form width-20" ng-show="ctrl.showTest">
<span class="gf-form-label width-13">Severity for test notification</span>
<div class="gf-form-select-wrapper width-7">
<select class="gf-form-input"
ng-model="ctrl.testSeverity"
ng-options="t for t in ['critical', 'warning', 'ok']">
</select>
</div>
</div>
<div class="gf-form" ng-show="ctrl.showTest"> <div class="gf-form" ng-show="ctrl.showTest">
<button ng-click="ctrl.testNotification()" class="btn btn-secondary">Send</button> <button ng-click="ctrl.testNotification()" class="btn btn-secondary">Send</button>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment