msg_test.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. defer gock.OffAll()
  20. httpMock("POST", d.msgURL).Reply(200).JSON(`{"code":0}`)
  21. err := d.MutliSendSysMsg(c, allUids, mc, title, context, ip)
  22. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  23. ctx.So(err, convey.ShouldBeNil)
  24. })
  25. })
  26. })
  27. }
  28. func TestMsgSendSysMsg(t *testing.T) {
  29. convey.Convey("SendSysMsg", t, func(ctx convey.C) {
  30. var (
  31. c = context.Background()
  32. uids = []int64{2}
  33. mc = "116_3_3"
  34. title = "11"
  35. content = "111"
  36. ip = "111.111.111.111"
  37. )
  38. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  39. defer gock.OffAll()
  40. httpMock("POST", d.msgURL).Reply(200).JSON(`{"code":0}`)
  41. err := d.SendSysMsg(c, uids, mc, title, content, ip)
  42. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  43. ctx.So(err, convey.ShouldBeNil)
  44. })
  45. })
  46. })
  47. }