grafana/pkg/tsdb/graphite/graphite_test.go

62 lines
1.6 KiB
Go
Raw Normal View History

package graphite
2016-11-02 02:00:18 -05:00
import (
. "github.com/smartystreets/goconvey/convey"
"testing"
)
func TestGraphiteFunctions(t *testing.T) {
Convey("Testing Graphite Functions", t, func() {
2016-11-02 02:00:18 -05:00
Convey("formatting time range for now", func() {
timeRange := formatTimeRange("now")
So(timeRange, ShouldEqual, "now")
})
Convey("formatting time range for now-1m", func() {
timeRange := formatTimeRange("now-1m")
So(timeRange, ShouldEqual, "-1min")
2016-11-02 02:00:18 -05:00
})
Convey("formatting time range for now-1M", func() {
timeRange := formatTimeRange("now-1M")
So(timeRange, ShouldEqual, "-1mon")
2016-11-02 02:00:18 -05:00
})
Convey("fix interval format in query for 1m", func() {
2016-11-03 00:31:59 -05:00
timeRange := fixIntervalFormat("aliasByNode(hitcount(averageSeries(app.grafana.*.dashboards.views.count), '1m'), 4)")
2016-11-02 02:00:18 -05:00
So(timeRange, ShouldEqual, "aliasByNode(hitcount(averageSeries(app.grafana.*.dashboards.views.count), '1min'), 4)")
})
Convey("fix interval format in query for 1M", func() {
2016-11-03 00:31:59 -05:00
timeRange := fixIntervalFormat("aliasByNode(hitcount(averageSeries(app.grafana.*.dashboards.views.count), '1M'), 4)")
2016-11-02 02:00:18 -05:00
So(timeRange, ShouldEqual, "aliasByNode(hitcount(averageSeries(app.grafana.*.dashboards.views.count), '1mon'), 4)")
})
2016-11-03 00:31:59 -05:00
Convey("should not override query for 1M", func() {
2016-11-02 13:11:06 -05:00
2016-11-03 00:31:59 -05:00
timeRange := fixIntervalFormat("app.grafana.*.dashboards.views.1M.count")
So(timeRange, ShouldEqual, "app.grafana.*.dashboards.views.1M.count")
2016-11-02 13:11:06 -05:00
2016-11-03 00:31:59 -05:00
})
2016-11-02 13:11:06 -05:00
2016-11-03 00:31:59 -05:00
Convey("should not override query for 1m", func() {
2016-11-02 13:11:06 -05:00
2016-11-03 00:31:59 -05:00
timeRange := fixIntervalFormat("app.grafana.*.dashboards.views.1m.count")
So(timeRange, ShouldEqual, "app.grafana.*.dashboards.views.1m.count")
2016-11-02 13:11:06 -05:00
2016-11-03 00:31:59 -05:00
})
2016-11-02 13:11:06 -05:00
2016-11-02 02:00:18 -05:00
})
}