prometheus_test.go 588 B

1234567891011121314151617181920212223242526
  1. package prometheus
  2. import (
  3. "testing"
  4. p "github.com/prometheus/common/model"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestPrometheus(t *testing.T) {
  8. Convey("Prometheus", t, func() {
  9. Convey("converting metric name", func() {
  10. metric := map[p.LabelName]p.LabelValue{
  11. p.LabelName("app"): p.LabelValue("backend"),
  12. p.LabelName("device"): p.LabelValue("mobile"),
  13. }
  14. query := &PrometheusQuery{
  15. LegendFormat: "legend {{app}} {{ device }} {{broken}}",
  16. }
  17. So(formatLegend(metric, query), ShouldEqual, "legend backend mobile {{broken}}")
  18. })
  19. })
  20. }