msg_test.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 TestDaoMutliSendSysMsg(t *testing.T) {
  9. convey.Convey("MutliSendSysMsg", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. allMids = []int64{27515256}
  13. title = "title"
  14. context = "context"
  15. )
  16. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  17. defer gock.OffAll()
  18. httpMock("GET", d.msgURL).Reply(200).JSON(`{"code":20007}`)
  19. err := d.MutliSendSysMsg(c, allMids, title, context)
  20. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  21. ctx.So(err, convey.ShouldNotBeNil)
  22. })
  23. })
  24. })
  25. }
  26. func TestDaoSendSysMsg(t *testing.T) {
  27. convey.Convey("SendSysMsg", t, func(ctx convey.C) {
  28. var (
  29. c = context.Background()
  30. mids = []int64{27515256}
  31. title = "title"
  32. context = "context"
  33. )
  34. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  35. defer gock.OffAll()
  36. httpMock("GET", d.msgURL).Reply(200).JSON(`{"code":20007}`)
  37. err := d.SendSysMsg(c, mids, title, context)
  38. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  39. ctx.So(err, convey.ShouldNotBeNil)
  40. })
  41. })
  42. })
  43. }