remotewriter_test.go 578 B

123456789101112131415161718192021222324252627282930
  1. package stat
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. "gopkg.in/h2non/gock.v1"
  6. )
  7. func TestRemoteWriter(t *testing.T) {
  8. defer gock.Off()
  9. gock.New("http://foo.com").Reply(200).BodyString("foo")
  10. writer := NewRemoteWriter("http://foo.com")
  11. err := writer.Write(&StatReport{
  12. Name: "bar",
  13. })
  14. assert.Nil(t, err)
  15. }
  16. func TestRemoteWriterFail(t *testing.T) {
  17. defer gock.Off()
  18. gock.New("http://foo.com").Reply(503).BodyString("foo")
  19. writer := NewRemoteWriter("http://foo.com")
  20. err := writer.Write(&StatReport{
  21. Name: "bar",
  22. })
  23. assert.NotNil(t, err)
  24. }