2016-09-21 04:17:29 -05:00
|
|
|
package prometheus
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
p "github.com/prometheus/common/model"
|
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestPrometheus(t *testing.T) {
|
|
|
|
Convey("Prometheus", t, func() {
|
|
|
|
|
|
|
|
Convey("converting metric name", func() {
|
|
|
|
metric := map[p.LabelName]p.LabelValue{
|
|
|
|
p.LabelName("app"): p.LabelValue("backend"),
|
|
|
|
p.LabelName("device"): p.LabelValue("mobile"),
|
|
|
|
}
|
|
|
|
|
2016-09-21 04:31:56 -05:00
|
|
|
query := &PrometheusQuery{
|
2016-10-19 01:57:58 -05:00
|
|
|
LegendFormat: "legend {{app}} {{ device }} {{broken}}",
|
2016-09-21 04:17:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
So(formatLegend(metric, query), ShouldEqual, "legend backend mobile {{broken}}")
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|