msg_test.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package msg
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. "gopkg.in/h2non/gock.v1"
  7. )
  8. func TestMsgMutliSendSysMsg(t *testing.T) {
  9. convey.Convey("MutliSendSysMsg", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. allUids = []int64{}
  13. mc = ""
  14. title = ""
  15. context = ""
  16. ip = ""
  17. )
  18. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  19. err := d.MutliSendSysMsg(c, allUids, mc, title, context, ip)
  20. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  21. ctx.So(err, convey.ShouldBeNil)
  22. })
  23. })
  24. })
  25. }
  26. func TestMsgSendSysMsg(t *testing.T) {
  27. convey.Convey("SendSysMsg", t, func(ctx convey.C) {
  28. var (
  29. c = context.Background()
  30. uids = []int64{}
  31. mc = ""
  32. title = ""
  33. context = ""
  34. ip = ""
  35. )
  36. defer gock.OffAll()
  37. httpMock("POST", "http://message.bilibili.co/api/notify/send.user.notify.do").Reply(200).JSON(`{"code": 0}`)
  38. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  39. err := d.SendSysMsg(c, uids, mc, title, context, ip)
  40. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  41. ctx.So(err, convey.ShouldBeNil)
  42. })
  43. })
  44. })
  45. }