blacklist_test.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "github.com/smartystreets/goconvey/convey"
  7. "go-common/app/job/main/growup/model"
  8. )
  9. func TestDaoListBlacklist(t *testing.T) {
  10. convey.Convey("ListBlacklist", t, func(ctx convey.C) {
  11. var (
  12. c = context.Background()
  13. query = "av_id=1"
  14. from = int(0)
  15. limit = int(100)
  16. )
  17. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  18. Exec(c, "INSERT INTO av_black_list(av_id, mid, reason, ctype, has_signed, nickname) VALUES (1,2,1,3,1,'test') ON DUPLICATE KEY UPDATE mid=VALUES(mid),reason=VALUES(reason),has_signed=VALUES(has_signed),nickname=VALUES(nickname)")
  19. backlists, err := d.ListBlacklist(c, query, from, limit)
  20. ctx.Convey("Then err should be nil.backlists should not be nil.", func(ctx convey.C) {
  21. ctx.So(err, convey.ShouldBeNil)
  22. ctx.So(backlists, convey.ShouldNotBeNil)
  23. })
  24. })
  25. })
  26. }
  27. func TestDaoGetExecuteOrder(t *testing.T) {
  28. convey.Convey("GetExecuteOrder", t, func(ctx convey.C) {
  29. var (
  30. c = context.Background()
  31. startTime = time.Now()
  32. endTime = time.Now()
  33. )
  34. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  35. executeOrders, err := d.GetExecuteOrder(c, startTime, endTime)
  36. ctx.Convey("Then err should not be nil.executeOrders should be nil.", func(ctx convey.C) {
  37. ctx.So(err, convey.ShouldBeNil)
  38. ctx.So(executeOrders, convey.ShouldBeNil)
  39. })
  40. })
  41. })
  42. }
  43. func TestDaoGetLastCtime(t *testing.T) {
  44. convey.Convey("GetLastCtime", t, func(ctx convey.C) {
  45. var (
  46. c = context.Background()
  47. reason = int(3)
  48. )
  49. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  50. ctime, err := d.GetLastCtime(c, reason)
  51. ctx.Convey("Then err should be nil.ctime should not be nil.", func(ctx convey.C) {
  52. ctx.So(err, convey.ShouldBeNil)
  53. ctx.So(ctime, convey.ShouldNotBeNil)
  54. })
  55. })
  56. })
  57. }
  58. func TestDaoAddBlacklistBatch(t *testing.T) {
  59. convey.Convey("AddBlacklistBatch", t, func(ctx convey.C) {
  60. var (
  61. c = context.Background()
  62. blacklist = []*model.Blacklist{
  63. &model.Blacklist{
  64. ID: int64(10),
  65. AvID: int64(100),
  66. MID: int64(3),
  67. Reason: 2,
  68. CType: 1,
  69. HasSigned: 1,
  70. Nickname: "test",
  71. },
  72. }
  73. )
  74. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  75. count, err := d.AddBlacklistBatch(c, blacklist)
  76. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  77. ctx.So(err, convey.ShouldBeNil)
  78. ctx.So(count, convey.ShouldNotBeNil)
  79. })
  80. })
  81. })
  82. }
  83. func TestDaoGetHasSignUpInfo(t *testing.T) {
  84. convey.Convey("GetHasSignUpInfo", t, func(ctx convey.C) {
  85. var (
  86. c = context.Background()
  87. offset = int(0)
  88. limit = int(100)
  89. m = make(map[int64]string)
  90. )
  91. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  92. err := d.GetHasSignUpInfo(c, offset, limit, m)
  93. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  94. ctx.So(err, convey.ShouldBeNil)
  95. })
  96. })
  97. })
  98. }