graphite_test.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package graphite
  2. import (
  3. . "github.com/smartystreets/goconvey/convey"
  4. "testing"
  5. )
  6. func TestGraphiteFunctions(t *testing.T) {
  7. Convey("Testing Graphite Functions", t, func() {
  8. Convey("formatting time range for now", func() {
  9. timeRange := formatTimeRange("now")
  10. So(timeRange, ShouldEqual, "now")
  11. })
  12. Convey("formatting time range for now-1m", func() {
  13. timeRange := formatTimeRange("now-1m")
  14. So(timeRange, ShouldEqual, "now-1min")
  15. })
  16. Convey("formatting time range for now-1M", func() {
  17. timeRange := formatTimeRange("now-1M")
  18. So(timeRange, ShouldEqual, "now-1mon")
  19. })
  20. Convey("fix interval format in query for 1m", func() {
  21. timeRange := formatTimeRange("aliasByNode(hitcount(averageSeries(app.grafana.*.dashboards.views.count), '1m'), 4)")
  22. So(timeRange, ShouldEqual, "aliasByNode(hitcount(averageSeries(app.grafana.*.dashboards.views.count), '1min'), 4)")
  23. })
  24. Convey("fix interval format in query for 1M", func() {
  25. timeRange := formatTimeRange("aliasByNode(hitcount(averageSeries(app.grafana.*.dashboards.views.count), '1M'), 4)")
  26. So(timeRange, ShouldEqual, "aliasByNode(hitcount(averageSeries(app.grafana.*.dashboards.views.count), '1mon'), 4)")
  27. })
  28. })
  29. }