Просмотр исходного кода

fix(build): trying to fix build

Torkel Ödegaard 9 лет назад
Родитель
Сommit
f5809c0209

+ 28 - 28
pkg/services/alerting/notifiers/base_test.go

@@ -1,30 +1,30 @@
 package notifiers
 
-import . "github.com/smartystreets/goconvey/convey"
-
-func TestBaseNotifier( /* t *testing.T */ ) {
-	// Convey("Parsing base notification state", t, func() {
-	//
-	// 	Convey("matches", func() {
-	// 		json := `
-	// 			{
-	// 				"states": "critical"
-	// 			}`
-	//
-	// 		settingsJSON, _ := simplejson.NewJson([]byte(json))
-	// 		not := NewNotifierBase("ops", "email", settingsJSON)
-	// 		So(not.MatchSeverity(m.AlertSeverityCritical), ShouldBeTrue)
-	// 	})
-	//
-	// 	Convey("does not match", func() {
-	// 		json := `
-	// 			{
-	// 				"severityFilter": "critical"
-	// 			}`
-	//
-	// 		settingsJSON, _ := simplejson.NewJson([]byte(json))
-	// 		not := NewNotifierBase("ops", "email", settingsJSON)
-	// 		So(not.MatchSeverity(m.AlertSeverityWarning), ShouldBeFalse)
-	// 	})
-	// })
-}
+// import . "github.com/smartystreets/goconvey/convey"
+//
+// func TestBaseNotifier( t *testing.T ) {
+// 	Convey("Parsing base notification state", t, func() {
+//
+// 		Convey("matches", func() {
+// 			json := `
+// 				{
+// 					"states": "critical"
+// 				}`
+//
+// 			settingsJSON, _ := simplejson.NewJson([]byte(json))
+// 			not := NewNotifierBase("ops", "email", settingsJSON)
+// 			So(not.MatchSeverity(m.AlertSeverityCritical), ShouldBeTrue)
+// 		})
+//
+// 		Convey("does not match", func() {
+// 			json := `
+// 				{
+// 					"severityFilter": "critical"
+// 				}`
+//
+// 			settingsJSON, _ := simplejson.NewJson([]byte(json))
+// 			not := NewNotifierBase("ops", "email", settingsJSON)
+// 			So(not.MatchSeverity(m.AlertSeverityWarning), ShouldBeFalse)
+// 		})
+// 	})
+// }

+ 6 - 10
pkg/services/alerting/test_notification.go

@@ -35,38 +35,34 @@ func handleNotificationTestCommand(cmd *NotificationTestCommand) error {
 		return err
 	}
 
-	notifier.sendNotifications([]Notifier{notifiers}, createTestEvalContext(cmd.State))
+	notifier.sendNotifications([]Notifier{notifiers}, createTestEvalContext())
 
 	return nil
 }
 
-func createTestEvalContext(state m.AlertStateType) *EvalContext {
+func createTestEvalContext() *EvalContext {
 
 	testRule := &Rule{
 		DashboardId: 1,
 		PanelId:     1,
 		Name:        "Test notification",
 		Message:     "Someone is testing the alert notification within grafana.",
-		State:       state,
+		State:       m.AlertStateAlerting,
 	}
 
 	ctx := NewEvalContext(testRule)
 	ctx.ImagePublicUrl = "http://grafana.org/assets/img/blog/mixed_styles.png"
 
 	ctx.IsTestRun = true
-	ctx.Firing = state == m.AlertStateAlerting
+	ctx.Firing = true
 	ctx.Error = nil
-	ctx.EvalMatches = evalMatchesBasedOnState(state)
+	ctx.EvalMatches = evalMatchesBasedOnState()
 
 	return ctx
 }
 
-func evalMatchesBasedOnState(state m.AlertStateType) []*EvalMatch {
+func evalMatchesBasedOnState() []*EvalMatch {
 	matches := make([]*EvalMatch, 0)
-	if state == m.AlertStateOK {
-		return matches
-	}
-
 	matches = append(matches, &EvalMatch{
 		Metric: "High value",
 		Value:  100,

+ 0 - 1
public/app/features/alerting/notification_edit_ctrl.ts

@@ -62,7 +62,6 @@ export class AlertNotificationEditCtrl {
       name: this.model.name,
       type: this.model.type,
       settings: this.model.settings,
-      severity: this.testSeverity
     };
 
     this.backendSrv.post(`/api/alert-notifications/test`, payload)

+ 0 - 18
public/app/features/alerting/partials/notification_edit.html

@@ -25,15 +25,6 @@
 				</select>
 			</div>
 		</div>
-		<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
 				class="gf-form"
@@ -86,16 +77,7 @@
 			<div class="gf-form width-8">
 				<button ng-click="ctrl.toggleTest()" class="btn btn-secondary">Test</button>
 			</div>
-
 			<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">
 				<button ng-click="ctrl.testNotification()" class="btn btn-secondary">Send</button>
 			</div>