up_info_video_test.go 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. package dao
  2. import (
  3. "context"
  4. // "go-common/library/time"
  5. "testing"
  6. "time"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDaoGetUpStateByMID(t *testing.T) {
  10. convey.Convey("GetUpStateByMID", t, func(ctx convey.C) {
  11. var (
  12. c = context.Background()
  13. mid = int64(10)
  14. )
  15. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  16. state, err := d.GetUpStateByMID(c, mid)
  17. ctx.Convey("Then err should be nil.state should not be nil.", func(ctx convey.C) {
  18. ctx.So(err, convey.ShouldBeNil)
  19. ctx.So(state, convey.ShouldNotBeNil)
  20. })
  21. })
  22. })
  23. }
  24. func TestDaoGetUpCreditScore(t *testing.T) {
  25. convey.Convey("GetUpCreditScore", t, func(ctx convey.C) {
  26. var (
  27. c = context.Background()
  28. mids = []int64{100}
  29. )
  30. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  31. scores, err := d.GetUpCreditScore(c, mids)
  32. ctx.Convey("Then err should be nil.scores should not be nil.", func(ctx convey.C) {
  33. ctx.So(err, convey.ShouldBeNil)
  34. ctx.So(scores, convey.ShouldNotBeNil)
  35. })
  36. })
  37. })
  38. }
  39. func TestDaoUpInfoVideo(t *testing.T) {
  40. convey.Convey("UpInfoVideo", t, func(ctx convey.C) {
  41. var (
  42. c = context.Background()
  43. offset = int64(0)
  44. limit = int64(100)
  45. )
  46. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  47. last, ups, err := d.UpInfoVideo(c, offset, limit)
  48. ctx.Convey("Then err should be nil.last,ups should not be nil.", func(ctx convey.C) {
  49. ctx.So(err, convey.ShouldBeNil)
  50. ctx.So(ups, convey.ShouldNotBeNil)
  51. ctx.So(last, convey.ShouldNotBeNil)
  52. })
  53. })
  54. })
  55. }
  56. func TestDaoMIDsByState(t *testing.T) {
  57. convey.Convey("MIDsByState", t, func(ctx convey.C) {
  58. var (
  59. c = context.Background()
  60. state = int(100)
  61. table = "up_info_video"
  62. )
  63. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  64. result, err := d.MIDsByState(c, state, table)
  65. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  66. ctx.So(err, convey.ShouldBeNil)
  67. ctx.So(result, convey.ShouldNotBeNil)
  68. })
  69. })
  70. })
  71. }
  72. func TestDaoMIDsByStateType(t *testing.T) {
  73. convey.Convey("MIDsByStateType", t, func(ctx convey.C) {
  74. var (
  75. c = context.Background()
  76. typ = int(2)
  77. state = int(3)
  78. table = "up_info_video"
  79. )
  80. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  81. result, err := d.MIDsByStateType(c, typ, state, table)
  82. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  83. ctx.So(err, convey.ShouldBeNil)
  84. ctx.So(result, convey.ShouldNotBeNil)
  85. })
  86. })
  87. })
  88. }
  89. func TestDaoUpdateAccountState(t *testing.T) {
  90. convey.Convey("UpdateAccountState", t, func(ctx convey.C) {
  91. var (
  92. c = context.Background()
  93. state = int(2)
  94. mids = []int64{100}
  95. table = "up_info_video"
  96. )
  97. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  98. rows, err := d.UpdateAccountState(c, state, mids, table)
  99. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  100. ctx.So(err, convey.ShouldBeNil)
  101. ctx.So(rows, convey.ShouldNotBeNil)
  102. })
  103. })
  104. })
  105. }
  106. func TestDaoGetDateSignedUps(t *testing.T) {
  107. convey.Convey("GetDateSignedUps", t, func(ctx convey.C) {
  108. var (
  109. c = context.Background()
  110. startAt = time.Now()
  111. endAt = time.Now()
  112. )
  113. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  114. count, err := d.GetDateSignedUps(c, startAt, endAt)
  115. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  116. ctx.So(err, convey.ShouldBeNil)
  117. ctx.So(count, convey.ShouldNotBeNil)
  118. })
  119. })
  120. })
  121. }
  122. func TestDaoGetAllSignedUps(t *testing.T) {
  123. convey.Convey("GetAllSignedUps", t, func(ctx convey.C) {
  124. var (
  125. c = context.Background()
  126. data = time.Now()
  127. )
  128. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  129. count, err := d.GetAllSignedUps(c, data)
  130. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  131. ctx.So(err, convey.ShouldBeNil)
  132. ctx.So(count, convey.ShouldNotBeNil)
  133. })
  134. })
  135. })
  136. }
  137. func TestDaoGetVideoApplyUpCount(t *testing.T) {
  138. convey.Convey("GetVideoApplyUpCount", t, func(ctx convey.C) {
  139. var (
  140. c = context.Background()
  141. startAt = time.Now()
  142. endAt = time.Now()
  143. )
  144. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  145. count, err := d.GetVideoApplyUpCount(c, startAt, endAt)
  146. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  147. ctx.So(err, convey.ShouldBeNil)
  148. ctx.So(count, convey.ShouldNotBeNil)
  149. })
  150. })
  151. })
  152. }
  153. func TestDaoGetUpBaseInfo(t *testing.T) {
  154. convey.Convey("GetUpBaseInfo", t, func(ctx convey.C) {
  155. var (
  156. c = context.Background()
  157. mid = []int64{100}
  158. )
  159. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  160. bs, err := d.GetUpBaseInfo(c, mid)
  161. ctx.Convey("Then err should be nil.bs should not be nil.", func(ctx convey.C) {
  162. ctx.So(err, convey.ShouldBeNil)
  163. ctx.So(bs, convey.ShouldNotBeNil)
  164. })
  165. })
  166. })
  167. }
  168. func TestDaoUpdateUpInfo(t *testing.T) {
  169. convey.Convey("UpdateUpInfo", t, func(ctx convey.C) {
  170. var (
  171. c = context.Background()
  172. values = "(1,2,3,4,5)"
  173. )
  174. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  175. rows, err := d.UpdateUpInfo(c, values)
  176. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  177. ctx.So(err, convey.ShouldBeNil)
  178. ctx.So(rows, convey.ShouldNotBeNil)
  179. })
  180. })
  181. })
  182. }
  183. func TestDaoMIDs(t *testing.T) {
  184. convey.Convey("MIDs", t, func(ctx convey.C) {
  185. var (
  186. c = context.Background()
  187. offset = int64(0)
  188. limit = int64(100)
  189. )
  190. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  191. last, mids, err := d.MIDs(c, offset, limit)
  192. ctx.Convey("Then err should be nil.last,mids should not be nil.", func(ctx convey.C) {
  193. ctx.So(err, convey.ShouldBeNil)
  194. ctx.So(mids, convey.ShouldNotBeNil)
  195. ctx.So(last, convey.ShouldNotBeNil)
  196. })
  197. })
  198. })
  199. }