httpclient_test.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package weeklyhonor
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. "gopkg.in/h2non/gock.v1"
  7. )
  8. func TestWeeklyhonorSendNotify(t *testing.T) {
  9. convey.Convey("SendNotify", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. mids = []int64{11}
  13. )
  14. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  15. defer gock.Off()
  16. httpMock("POST", d.c.Host.Message+_notifyURL).Reply(200).JSON(`{"code":0,"data":{}}`)
  17. _, err := d.SendNotify(c, mids)
  18. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  19. ctx.So(err, convey.ShouldEqual, err)
  20. })
  21. })
  22. })
  23. }
  24. func TestWeeklyhonorUpMids(t *testing.T) {
  25. convey.Convey("UpMids", t, func(ctx convey.C) {
  26. var (
  27. c = context.Background()
  28. size = int(0)
  29. lastid = int64(0)
  30. activeOnly bool
  31. )
  32. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  33. mids, newid, err := d.UpMids(c, size, lastid, activeOnly)
  34. ctx.Convey("Then err should be nil.mids,newid should not be nil.", func(ctx convey.C) {
  35. ctx.So(err, convey.ShouldBeNil)
  36. ctx.So(newid, convey.ShouldNotBeNil)
  37. ctx.So(mids, convey.ShouldNotBeNil)
  38. })
  39. })
  40. })
  41. }