message_test.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package dao
  2. import (
  3. "context"
  4. "gopkg.in/h2non/gock.v1"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoMessage(t *testing.T) {
  9. convey.Convey("Message", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. title = "abc test"
  13. msg = "abc"
  14. mids = []int64{112}
  15. mc = "2_2_2"
  16. )
  17. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  18. defer gock.OffAll()
  19. httpMock("POST", d.msgURL).Reply(200).JSON(`{"code":0}`)
  20. err := d.RawMessage(c, mc, title, msg, mids)
  21. ctx.So(err, convey.ShouldBeNil)
  22. })
  23. })
  24. }
  25. func TestDaoRawMessage(t *testing.T) {
  26. convey.Convey("RawMessage", t, func(ctx convey.C) {
  27. var (
  28. c = context.Background()
  29. mc = "2_2_2"
  30. title = "abc test"
  31. msg = "abc test"
  32. mids = []int64{112}
  33. )
  34. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  35. defer gock.OffAll()
  36. httpMock("POST", d.msgURL).Reply(200).JSON(`{"code":0}`)
  37. err := d.RawMessage(c, mc, title, msg, mids)
  38. ctx.So(err, convey.ShouldBeNil)
  39. })
  40. })
  41. }