wechat_test.go 753 B

1234567891011121314151617181920212223242526272829
  1. package bnj
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. "gopkg.in/h2non/gock.v1"
  7. )
  8. func TestBnjSendWechat(t *testing.T) {
  9. convey.Convey("SendWechat", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. title = "【拜年祭必看!】拜年祭预约人数到达预警"
  13. msg = "拜年祭预约人数即将到达50w,请及时准备拜年祭抽奖事项。"
  14. user = "wuhao02"
  15. )
  16. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  17. defer gock.OffAll()
  18. httpMock("POST", _wechatURL).Reply(200).JSON(`{"RetCode":0}`)
  19. err := d.SendWechat(c, title, msg, user)
  20. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  21. ctx.So(err, convey.ShouldBeNil)
  22. })
  23. })
  24. })
  25. }