graphite_test.go 712 B

12345678910111213141516171819202122232425262728293031
  1. package metrics
  2. import (
  3. "testing"
  4. "github.com/grafana/grafana/pkg/setting"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestGraphitePublisher(t *testing.T) {
  8. Convey("Test graphite prefix", t, func() {
  9. err := setting.NewConfigContext(&setting.CommandLineArgs{
  10. HomePath: "../../",
  11. Args: []string{
  12. "cfg:metrics.graphite.prefix=service.grafana.%instance_name%",
  13. "cfg:metrics.graphite.address=localhost:2003",
  14. },
  15. })
  16. So(err, ShouldBeNil)
  17. setting.InstanceName = "hostname.with.dots.com"
  18. publisher, err2 := CreateGraphitePublisher()
  19. So(err2, ShouldBeNil)
  20. So(publisher, ShouldNotBeNil)
  21. So(publisher.prefix, ShouldEqual, "service.grafana.hostname_with_dots_com")
  22. })
  23. }