mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
style: go fmt with simplify
This commit is contained in:
parent
1df9c2cab3
commit
46e4a54a6e
@ -39,7 +39,7 @@ func TestAlertingEvaluationHandler(t *testing.T) {
|
|||||||
Convey("Show return false with not passing asdf", func() {
|
Convey("Show return false with not passing asdf", func() {
|
||||||
context := NewEvalContext(context.TODO(), &Rule{
|
context := NewEvalContext(context.TODO(), &Rule{
|
||||||
Conditions: []Condition{
|
Conditions: []Condition{
|
||||||
&conditionStub{firing: true, operator: "and", matches: []*EvalMatch{&EvalMatch{}, &EvalMatch{}}},
|
&conditionStub{firing: true, operator: "and", matches: []*EvalMatch{{}, {}}},
|
||||||
&conditionStub{firing: false, operator: "and"},
|
&conditionStub{firing: false, operator: "and"},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
package notifiers
|
package notifiers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/grafana/grafana/pkg/log"
|
|
||||||
"github.com/grafana/grafana/pkg/services/alerting"
|
|
||||||
m "github.com/grafana/grafana/pkg/models"
|
|
||||||
"github.com/grafana/grafana/pkg/metrics"
|
|
||||||
"net/url"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/grafana/grafana/pkg/bus"
|
"github.com/grafana/grafana/pkg/bus"
|
||||||
|
"github.com/grafana/grafana/pkg/log"
|
||||||
|
"github.com/grafana/grafana/pkg/metrics"
|
||||||
|
m "github.com/grafana/grafana/pkg/models"
|
||||||
|
"github.com/grafana/grafana/pkg/services/alerting"
|
||||||
|
"net/url"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
alerting.RegisterNotifier(&alerting.NotifierPlugin{
|
alerting.RegisterNotifier(&alerting.NotifierPlugin{
|
||||||
Type: "LINE",
|
Type: "LINE",
|
||||||
Name: "LINE",
|
Name: "LINE",
|
||||||
Description: "Send notifications to LINE notify",
|
Description: "Send notifications to LINE notify",
|
||||||
Factory: NewLINENotifier,
|
Factory: NewLINENotifier,
|
||||||
OptionsTemplate: `
|
OptionsTemplate: `
|
||||||
<div class="gf-form-group">
|
<div class="gf-form-group">
|
||||||
<h3 class="page-heading">LINE notify settings</h3>
|
<h3 class="page-heading">LINE notify settings</h3>
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
package notifiers
|
package notifiers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -113,7 +113,7 @@ func HandleAlertsQuery(query *m.GetAlertsQuery) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, _ := range alerts {
|
for i := range alerts {
|
||||||
if alerts[i].ExecutionError == " " {
|
if alerts[i].ExecutionError == " " {
|
||||||
alerts[i].ExecutionError = ""
|
alerts[i].ExecutionError = ""
|
||||||
}
|
}
|
||||||
|
@ -128,43 +128,43 @@ func TestInfluxdbQueryBuilder(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
Convey("can render normal tags without operator", func() {
|
Convey("can render normal tags without operator", func() {
|
||||||
query := &Query{Tags: []*Tag{&Tag{Operator: "", Value: `value`, Key: "key"}}}
|
query := &Query{Tags: []*Tag{{Operator: "", Value: `value`, Key: "key"}}}
|
||||||
|
|
||||||
So(strings.Join(query.renderTags(), ""), ShouldEqual, `"key" = 'value'`)
|
So(strings.Join(query.renderTags(), ""), ShouldEqual, `"key" = 'value'`)
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("can render regex tags without operator", func() {
|
Convey("can render regex tags without operator", func() {
|
||||||
query := &Query{Tags: []*Tag{&Tag{Operator: "", Value: `/value/`, Key: "key"}}}
|
query := &Query{Tags: []*Tag{{Operator: "", Value: `/value/`, Key: "key"}}}
|
||||||
|
|
||||||
So(strings.Join(query.renderTags(), ""), ShouldEqual, `"key" =~ /value/`)
|
So(strings.Join(query.renderTags(), ""), ShouldEqual, `"key" =~ /value/`)
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("can render regex tags", func() {
|
Convey("can render regex tags", func() {
|
||||||
query := &Query{Tags: []*Tag{&Tag{Operator: "=~", Value: `/value/`, Key: "key"}}}
|
query := &Query{Tags: []*Tag{{Operator: "=~", Value: `/value/`, Key: "key"}}}
|
||||||
|
|
||||||
So(strings.Join(query.renderTags(), ""), ShouldEqual, `"key" =~ /value/`)
|
So(strings.Join(query.renderTags(), ""), ShouldEqual, `"key" =~ /value/`)
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("can render number tags", func() {
|
Convey("can render number tags", func() {
|
||||||
query := &Query{Tags: []*Tag{&Tag{Operator: "=", Value: "10001", Key: "key"}}}
|
query := &Query{Tags: []*Tag{{Operator: "=", Value: "10001", Key: "key"}}}
|
||||||
|
|
||||||
So(strings.Join(query.renderTags(), ""), ShouldEqual, `"key" = '10001'`)
|
So(strings.Join(query.renderTags(), ""), ShouldEqual, `"key" = '10001'`)
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("can render numbers less then condition tags", func() {
|
Convey("can render numbers less then condition tags", func() {
|
||||||
query := &Query{Tags: []*Tag{&Tag{Operator: "<", Value: "10001", Key: "key"}}}
|
query := &Query{Tags: []*Tag{{Operator: "<", Value: "10001", Key: "key"}}}
|
||||||
|
|
||||||
So(strings.Join(query.renderTags(), ""), ShouldEqual, `"key" < 10001`)
|
So(strings.Join(query.renderTags(), ""), ShouldEqual, `"key" < 10001`)
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("can render number greather then condition tags", func() {
|
Convey("can render number greather then condition tags", func() {
|
||||||
query := &Query{Tags: []*Tag{&Tag{Operator: ">", Value: "10001", Key: "key"}}}
|
query := &Query{Tags: []*Tag{{Operator: ">", Value: "10001", Key: "key"}}}
|
||||||
|
|
||||||
So(strings.Join(query.renderTags(), ""), ShouldEqual, `"key" > 10001`)
|
So(strings.Join(query.renderTags(), ""), ShouldEqual, `"key" > 10001`)
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("can render string tags", func() {
|
Convey("can render string tags", func() {
|
||||||
query := &Query{Tags: []*Tag{&Tag{Operator: "=", Value: "value", Key: "key"}}}
|
query := &Query{Tags: []*Tag{{Operator: "=", Value: "value", Key: "key"}}}
|
||||||
|
|
||||||
So(strings.Join(query.renderTags(), ""), ShouldEqual, `"key" = 'value'`)
|
So(strings.Join(query.renderTags(), ""), ShouldEqual, `"key" = 'value'`)
|
||||||
})
|
})
|
||||||
|
@ -19,7 +19,7 @@ func TestInfluxdbResponseParser(t *testing.T) {
|
|||||||
|
|
||||||
response := &Response{
|
response := &Response{
|
||||||
Results: []Result{
|
Results: []Result{
|
||||||
Result{
|
{
|
||||||
Series: []Row{
|
Series: []Row{
|
||||||
{
|
{
|
||||||
Name: "cpu",
|
Name: "cpu",
|
||||||
@ -69,7 +69,7 @@ func TestInfluxdbResponseParser(t *testing.T) {
|
|||||||
|
|
||||||
response := &Response{
|
response := &Response{
|
||||||
Results: []Result{
|
Results: []Result{
|
||||||
Result{
|
{
|
||||||
Series: []Row{
|
Series: []Row{
|
||||||
{
|
{
|
||||||
Name: "cpu.upc",
|
Name: "cpu.upc",
|
||||||
|
@ -27,16 +27,16 @@ func TestWildcardExpansion(t *testing.T) {
|
|||||||
Convey("Without wildcard series", func() {
|
Convey("Without wildcard series", func() {
|
||||||
query := &Query{
|
query := &Query{
|
||||||
Metrics: []Metric{
|
Metrics: []Metric{
|
||||||
Metric{Metric: "os.cpu.3.idle", Alias: ""},
|
{Metric: "os.cpu.3.idle", Alias: ""},
|
||||||
Metric{Metric: "os.cpu.2.idle", Alias: ""},
|
{Metric: "os.cpu.2.idle", Alias: ""},
|
||||||
Metric{Metric: "os.cpu.1.idle", Alias: "cpu"},
|
{Metric: "os.cpu.1.idle", Alias: "cpu"},
|
||||||
},
|
},
|
||||||
Hosts: []string{"staples-lab-1", "staples-lab-2"},
|
Hosts: []string{"staples-lab-1", "staples-lab-2"},
|
||||||
Cluster: []string{"demoapp-1", "demoapp-2"},
|
Cluster: []string{"demoapp-1", "demoapp-2"},
|
||||||
AddClusterToAlias: false,
|
AddClusterToAlias: false,
|
||||||
AddHostToAlias: false,
|
AddHostToAlias: false,
|
||||||
FunctionList: []Function{
|
FunctionList: []Function{
|
||||||
Function{Func: "aggregate.min"},
|
{Func: "aggregate.min"},
|
||||||
},
|
},
|
||||||
TimeRange: &tsdb.TimeRange{Now: now, From: "5m", To: "now"},
|
TimeRange: &tsdb.TimeRange{Now: now, From: "5m", To: "now"},
|
||||||
}
|
}
|
||||||
@ -52,15 +52,15 @@ func TestWildcardExpansion(t *testing.T) {
|
|||||||
Convey("With two aggregate functions", func() {
|
Convey("With two aggregate functions", func() {
|
||||||
query := &Query{
|
query := &Query{
|
||||||
Metrics: []Metric{
|
Metrics: []Metric{
|
||||||
Metric{Metric: "os.cpu.3.idle", Alias: ""},
|
{Metric: "os.cpu.3.idle", Alias: ""},
|
||||||
},
|
},
|
||||||
Hosts: []string{"staples-lab-1", "staples-lab-2"},
|
Hosts: []string{"staples-lab-1", "staples-lab-2"},
|
||||||
Cluster: []string{"demoapp-1", "demoapp-2"},
|
Cluster: []string{"demoapp-1", "demoapp-2"},
|
||||||
AddClusterToAlias: false,
|
AddClusterToAlias: false,
|
||||||
AddHostToAlias: false,
|
AddHostToAlias: false,
|
||||||
FunctionList: []Function{
|
FunctionList: []Function{
|
||||||
Function{Func: "aggregate.min"},
|
{Func: "aggregate.min"},
|
||||||
Function{Func: "aggregate.max"},
|
{Func: "aggregate.max"},
|
||||||
},
|
},
|
||||||
TimeRange: &tsdb.TimeRange{Now: now, From: "5m", To: "now"},
|
TimeRange: &tsdb.TimeRange{Now: now, From: "5m", To: "now"},
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ func TestWildcardExpansion(t *testing.T) {
|
|||||||
Convey("Containg wildcard series", func() {
|
Convey("Containg wildcard series", func() {
|
||||||
query := &Query{
|
query := &Query{
|
||||||
Metrics: []Metric{
|
Metrics: []Metric{
|
||||||
Metric{Metric: "os.cpu*", Alias: ""},
|
{Metric: "os.cpu*", Alias: ""},
|
||||||
},
|
},
|
||||||
Hosts: []string{"staples-lab-1"},
|
Hosts: []string{"staples-lab-1"},
|
||||||
AddClusterToAlias: false,
|
AddClusterToAlias: false,
|
||||||
|
Loading…
Reference in New Issue
Block a user