http_test.go 672 B

1234567891011121314151617181920212223242526272829
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. gock "gopkg.in/h2non/gock.v1"
  7. )
  8. func TestDaoSendMessage(t *testing.T) {
  9. convey.Convey("SendMessage", t, func(convCtx convey.C) {
  10. var (
  11. c = context.Background()
  12. mids = ""
  13. title = ""
  14. content = ""
  15. ip = ""
  16. )
  17. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  18. defer gock.OffAll()
  19. httpMock("POST", sendMessage).Reply(200).JSON(`{"code":0}`)
  20. err := d.SendMessage(c, mids, title, content, ip)
  21. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  22. convCtx.So(err, convey.ShouldBeNil)
  23. })
  24. })
  25. })
  26. }