business_test.go 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. gock "gopkg.in/h2non/gock.v1"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDaoLoginout(t *testing.T) {
  10. var (
  11. c = context.Background()
  12. mid = int64(1)
  13. )
  14. convey.Convey("TestDaoLoginout", t, func(ctx convey.C) {
  15. defer gock.OffAll()
  16. httpMock("POST", d.loginOutURL).Reply(200).JSON(`{"code":0}`)
  17. err := d.Loginout(c, mid)
  18. ctx.Convey("Error should be nil", func(ctx convey.C) {
  19. ctx.So(err, convey.ShouldBeNil)
  20. })
  21. })
  22. }
  23. func TestDaoSendCleanCache(t *testing.T) {
  24. var (
  25. c = context.TODO()
  26. mid = int64(0)
  27. months = int16(0)
  28. days = int64(0)
  29. no = int(0)
  30. ip = ""
  31. )
  32. convey.Convey("SendCleanCache", t, func(ctx convey.C) {
  33. err := d.SendCleanCache(c, mid, months, days, no, ip)
  34. ctx.Convey("Error should be nil", func(ctx convey.C) {
  35. ctx.So(err, convey.ShouldBeNil)
  36. })
  37. })
  38. }
  39. func TestDaoSendMultipMsg(t *testing.T) {
  40. var (
  41. c = context.TODO()
  42. mids = ""
  43. content = ""
  44. title = ""
  45. mc = ""
  46. ip = ""
  47. dataType = int(0)
  48. )
  49. convey.Convey("SendMultipMsg", t, func(ctx convey.C) {
  50. defer gock.OffAll()
  51. httpMock("POST", d.msgURI).Reply(200).JSON(`{"code":0}`)
  52. err := d.SendMultipMsg(c, mids, content, title, mc, ip, dataType)
  53. ctx.Convey("Error should be nil", func(ctx convey.C) {
  54. ctx.So(err, convey.ShouldBeNil)
  55. })
  56. })
  57. }
  58. func TestDaoSendBcoinCoupon(t *testing.T) {
  59. var (
  60. c = context.TODO()
  61. mids = "20606508"
  62. activityID = "1"
  63. money = int64(0)
  64. dueTime = time.Now()
  65. )
  66. convey.Convey("SendBcoinCoupon", t, func(ctx convey.C) {
  67. defer gock.OffAll()
  68. httpMock("POST", d.payURI).Reply(200).JSON(`{"code":0}`)
  69. err := d.SendBcoinCoupon(c, mids, activityID, money, dueTime)
  70. ctx.Convey("Error should be nil", func(ctx convey.C) {
  71. ctx.So(err, convey.ShouldBeNil)
  72. })
  73. })
  74. }