db_test.go 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. package newcomer
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestNewcomerUserTasks(t *testing.T) {
  9. convey.Convey("UserTasks", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. index = ""
  13. id = int64(0)
  14. limit = int(100)
  15. )
  16. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  17. _, err := d.UserTasks(c, index, id, limit)
  18. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  19. ctx.So(err, convey.ShouldEqual, err)
  20. })
  21. })
  22. })
  23. }
  24. func TestNewcomergetTableName(t *testing.T) {
  25. convey.Convey("getTableName", t, func(ctx convey.C) {
  26. var (
  27. mid = int64(27515405)
  28. )
  29. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  30. p1 := getTableName(mid)
  31. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  32. ctx.So(p1, convey.ShouldEqual, p1)
  33. })
  34. })
  35. })
  36. }
  37. func TestNewcomerUpUserTask(t *testing.T) {
  38. convey.Convey("UpUserTask", t, func(ctx convey.C) {
  39. var (
  40. c = context.Background()
  41. mid = int64(27515405)
  42. tid = int64(1)
  43. )
  44. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  45. _, err := d.UpUserTask(c, mid, tid)
  46. ctx.Convey("Then err should be nil.p1 should not be nil.", func(ctx convey.C) {
  47. ctx.So(err, convey.ShouldEqual, err)
  48. })
  49. })
  50. })
  51. }
  52. func TestNewcomerUserTasksByMID(t *testing.T) {
  53. convey.Convey("UserTasksByMID", t, func(ctx convey.C) {
  54. var (
  55. c = context.Background()
  56. mid = int64(27515405)
  57. )
  58. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  59. _, err := d.UserTasksByMID(c, mid)
  60. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  61. ctx.So(err, convey.ShouldEqual, err)
  62. })
  63. })
  64. })
  65. }
  66. func TestNewcomerTaskByTID(t *testing.T) {
  67. convey.Convey("TaskByTID", t, func(ctx convey.C) {
  68. var (
  69. c = context.Background()
  70. mid = int64(27515405)
  71. tid = int64(1)
  72. )
  73. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  74. _, err := d.TaskByTID(c, mid, tid)
  75. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  76. ctx.So(err, convey.ShouldEqual, err)
  77. })
  78. })
  79. })
  80. }
  81. func TestNewcomerTasks(t *testing.T) {
  82. convey.Convey("Tasks", t, func(ctx convey.C) {
  83. var (
  84. c = context.Background()
  85. )
  86. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  87. _, err := d.Tasks(c)
  88. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  89. ctx.So(err, convey.ShouldEqual, err)
  90. })
  91. })
  92. })
  93. }
  94. func TestNewcomerCheckTaskComplete(t *testing.T) {
  95. convey.Convey("CheckTaskComplete", t, func(ctx convey.C) {
  96. var (
  97. c = context.Background()
  98. mid = int64(27515405)
  99. tid = int64(1)
  100. )
  101. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  102. res := d.CheckTaskComplete(c, mid, tid)
  103. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  104. ctx.So(res, convey.ShouldEqual, res)
  105. })
  106. })
  107. })
  108. }
  109. func TestNewcomerUserTasksNotify(t *testing.T) {
  110. convey.Convey("UserTasksNotify", t, func(ctx convey.C) {
  111. var (
  112. c = context.Background()
  113. id = int64(0)
  114. index = "1"
  115. start = time.Now().Format("2006-01-02 15:04:05")
  116. end = time.Now().Format("2006-01-02 15:04:05")
  117. limit = 100
  118. )
  119. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  120. _, err := d.UserTasksNotify(c, index, id, start, end, limit)
  121. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  122. ctx.So(err, convey.ShouldEqual, err)
  123. })
  124. })
  125. })
  126. }
  127. func TestNewcomerGiftRewardCount(t *testing.T) {
  128. convey.Convey("GiftRewardCount", t, func(ctx convey.C) {
  129. var (
  130. c = context.Background()
  131. mid = int64(27515405)
  132. )
  133. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  134. _, err := d.GiftRewardCount(c, mid)
  135. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  136. ctx.So(err, convey.ShouldEqual, err)
  137. })
  138. })
  139. })
  140. }
  141. func TestNewcomerBaseRewardCount(t *testing.T) {
  142. convey.Convey("BaseRewardCount", t, func(ctx convey.C) {
  143. var (
  144. c = context.Background()
  145. mid = int64(27515405)
  146. )
  147. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  148. _, err := d.BaseRewardCount(c, mid)
  149. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  150. ctx.So(err, convey.ShouldEqual, err)
  151. })
  152. })
  153. })
  154. }
  155. func TestNewcomerCheckTasksForRewardNotify(t *testing.T) {
  156. convey.Convey("CheckTasksForRewardNotify", t, func(ctx convey.C) {
  157. var (
  158. c = context.Background()
  159. id = int64(0)
  160. index = "1"
  161. start = time.Now()
  162. end = time.Now()
  163. limit = 100
  164. )
  165. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  166. _, err := d.CheckTasksForRewardNotify(c, index, id, start, end, limit)
  167. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  168. ctx.So(err, convey.ShouldEqual, err)
  169. })
  170. })
  171. })
  172. }
  173. func TestNewcomerUserTasksByMIDAndState(t *testing.T) {
  174. convey.Convey("UserTasksByMIDAndState", t, func(ctx convey.C) {
  175. var (
  176. c = context.Background()
  177. mid = int64(27515405)
  178. state = 0
  179. )
  180. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  181. _, err := d.UserTasksByMIDAndState(c, mid, state)
  182. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  183. ctx.So(err, convey.ShouldEqual, err)
  184. })
  185. })
  186. })
  187. }