http_test.go 653 B

1234567891011121314151617181920212223242526272829
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. gock "gopkg.in/h2non/gock.v1"
  6. "github.com/smartystreets/goconvey/convey"
  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. content = ""
  14. title = ""
  15. )
  16. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  17. defer gock.OffAll()
  18. httpMock("POST", sendMessage).Reply(200).JSON(`{"code":0}`)
  19. err := d.SendMessage(c, mids, content, title)
  20. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  21. convCtx.So(err, convey.ShouldBeNil)
  22. })
  23. })
  24. })
  25. }