graphite_test.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 := fixIntervalFormat("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 := fixIntervalFormat("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. Convey("should not override query for 1M", func() {
  29. timeRange := fixIntervalFormat("app.grafana.*.dashboards.views.1M.count")
  30. So(timeRange, ShouldEqual, "app.grafana.*.dashboards.views.1M.count")
  31. })
  32. Convey("should not override query for 1m", func() {
  33. timeRange := fixIntervalFormat("app.grafana.*.dashboards.views.1m.count")
  34. So(timeRange, ShouldEqual, "app.grafana.*.dashboards.views.1m.count")
  35. })
  36. })
  37. }