mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
test(alerting): improve naming for test scenario
This commit is contained in:
parent
e082d78697
commit
2bdd2a59cb
@ -11,25 +11,6 @@ import (
|
|||||||
|
|
||||||
func TestSimpleReducer(t *testing.T) {
|
func TestSimpleReducer(t *testing.T) {
|
||||||
Convey("Test simple reducer by calculating", t, func() {
|
Convey("Test simple reducer by calculating", t, func() {
|
||||||
Convey("avg", func() {
|
|
||||||
result := testReducer("avg", 1, 2, 3)
|
|
||||||
So(result, ShouldEqual, float64(2))
|
|
||||||
})
|
|
||||||
|
|
||||||
Convey("avg of none null data", func() {
|
|
||||||
reducer := NewSimpleReducer("avg")
|
|
||||||
series := &tsdb.TimeSeries{
|
|
||||||
Name: "test time serie",
|
|
||||||
}
|
|
||||||
|
|
||||||
series.Points = append(series.Points, tsdb.NewTimePoint(null.FloatFrom(3), 1))
|
|
||||||
series.Points = append(series.Points, tsdb.NewTimePoint(null.FloatFromPtr(nil), 2))
|
|
||||||
series.Points = append(series.Points, tsdb.NewTimePoint(null.FloatFromPtr(nil), 3))
|
|
||||||
series.Points = append(series.Points, tsdb.NewTimePoint(null.FloatFrom(3), 4))
|
|
||||||
|
|
||||||
So(reducer.Reduce(series).Float64, ShouldEqual, float64(3))
|
|
||||||
})
|
|
||||||
|
|
||||||
Convey("sum", func() {
|
Convey("sum", func() {
|
||||||
result := testReducer("sum", 1, 2, 3)
|
result := testReducer("sum", 1, 2, 3)
|
||||||
So(result, ShouldEqual, float64(6))
|
So(result, ShouldEqual, float64(6))
|
||||||
@ -69,6 +50,25 @@ func TestSimpleReducer(t *testing.T) {
|
|||||||
result := testReducer("median", 1)
|
result := testReducer("median", 1)
|
||||||
So(result, ShouldEqual, float64(1))
|
So(result, ShouldEqual, float64(1))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Convey("avg", func() {
|
||||||
|
result := testReducer("avg", 1, 2, 3)
|
||||||
|
So(result, ShouldEqual, float64(2))
|
||||||
|
})
|
||||||
|
|
||||||
|
Convey("avg of number values and null values should ignore nulls", func() {
|
||||||
|
reducer := NewSimpleReducer("avg")
|
||||||
|
series := &tsdb.TimeSeries{
|
||||||
|
Name: "test time serie",
|
||||||
|
}
|
||||||
|
|
||||||
|
series.Points = append(series.Points, tsdb.NewTimePoint(null.FloatFrom(3), 1))
|
||||||
|
series.Points = append(series.Points, tsdb.NewTimePoint(null.FloatFromPtr(nil), 2))
|
||||||
|
series.Points = append(series.Points, tsdb.NewTimePoint(null.FloatFromPtr(nil), 3))
|
||||||
|
series.Points = append(series.Points, tsdb.NewTimePoint(null.FloatFrom(3), 4))
|
||||||
|
|
||||||
|
So(reducer.Reduce(series).Float64, ShouldEqual, float64(3))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user