mysql_test.go 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoBeginTran(t *testing.T) {
  9. convey.Convey("BeginTran", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. )
  13. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  14. tx, err := d.BeginTran(c)
  15. ctx.Convey("Then err should be nil.tx should not be nil.", func(ctx convey.C) {
  16. ctx.So(err, convey.ShouldBeNil)
  17. ctx.So(tx, convey.ShouldNotBeNil)
  18. })
  19. })
  20. })
  21. }
  22. func TestDaoRawElecUPRankList(t *testing.T) {
  23. convey.Convey("RawElecUPRankList", t, func(ctx convey.C) {
  24. var (
  25. c = context.Background()
  26. upMID = int64(15555180)
  27. ver = int64(0)
  28. limit = int(10)
  29. )
  30. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  31. list, err := d.RawElecUPRankList(c, upMID, ver, limit)
  32. ctx.Convey("Then err should be nil.list should not be nil.", func(ctx convey.C) {
  33. ctx.So(err, convey.ShouldBeNil)
  34. ctx.So(list, convey.ShouldNotBeNil)
  35. })
  36. })
  37. })
  38. }
  39. func TestDaoRawElecUPRank(t *testing.T) {
  40. convey.Convey("RawElecUPRank", t, func(ctx convey.C) {
  41. var (
  42. c = context.Background()
  43. upMID = int64(15555180)
  44. ver = int64(0)
  45. payMID = int64(14137123)
  46. )
  47. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  48. data, err := d.RawElecUPRank(c, upMID, ver, payMID)
  49. ctx.Convey("Then err should be nil.data should not be nil.", func(ctx convey.C) {
  50. ctx.So(err, convey.ShouldBeNil)
  51. ctx.So(data, convey.ShouldNotBeNil)
  52. })
  53. })
  54. })
  55. }
  56. func TestDaoRawCountElecUPRank(t *testing.T) {
  57. convey.Convey("RawCountElecUPRank", t, func(ctx convey.C) {
  58. var (
  59. c = context.Background()
  60. upMID = int64(15555180)
  61. ver = int64(0)
  62. )
  63. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  64. count, err := d.RawCountElecUPRank(c, upMID, ver)
  65. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  66. ctx.So(err, convey.ShouldBeNil)
  67. ctx.So(count, convey.ShouldNotBeNil)
  68. })
  69. })
  70. })
  71. }
  72. func TestDaoRawElecAVRankList(t *testing.T) {
  73. convey.Convey("RawElecAVRankList", t, func(ctx convey.C) {
  74. var (
  75. c = context.Background()
  76. avID = int64(4052629)
  77. ver = int64(0)
  78. limit = int(10)
  79. )
  80. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  81. list, err := d.RawElecAVRankList(c, avID, ver, limit)
  82. ctx.Convey("Then err should be nil.list should not be nil.", func(ctx convey.C) {
  83. ctx.So(err, convey.ShouldBeNil)
  84. ctx.So(list, convey.ShouldNotBeNil)
  85. })
  86. })
  87. })
  88. }
  89. func TestDaoRawElecAVRank(t *testing.T) {
  90. convey.Convey("RawElecAVRank", t, func(ctx convey.C) {
  91. var (
  92. c = context.Background()
  93. avID = int64(4052629)
  94. ver = int64(0)
  95. payMID = int64(4780461)
  96. )
  97. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  98. data, err := d.RawElecAVRank(c, avID, ver, payMID)
  99. ctx.Convey("Then err should be nil.data should not be nil.", func(ctx convey.C) {
  100. ctx.So(err, convey.ShouldBeNil)
  101. ctx.So(data, convey.ShouldNotBeNil)
  102. })
  103. })
  104. })
  105. }
  106. func TestDaoRawCountElecAVRank(t *testing.T) {
  107. convey.Convey("RawCountElecAVRank", t, func(ctx convey.C) {
  108. var (
  109. c = context.Background()
  110. avID = int64(4052629)
  111. ver = int64(0)
  112. )
  113. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  114. count, err := d.RawCountElecAVRank(c, avID, ver)
  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 TestDaoRawElecUPMessages(t *testing.T) {
  123. convey.Convey("RawElecUPMessages", t, func(ctx convey.C) {
  124. var (
  125. c = context.Background()
  126. payMIDs = []int64{27515316}
  127. upMID = int64(27515241)
  128. ver = int64(201705)
  129. )
  130. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  131. dataMap, err := d.RawElecUPMessages(c, payMIDs, upMID, ver)
  132. ctx.Convey("Then err should be nil.dataMap should not be nil.", func(ctx convey.C) {
  133. ctx.So(err, convey.ShouldBeNil)
  134. ctx.So(dataMap, convey.ShouldNotBeNil)
  135. })
  136. })
  137. })
  138. }
  139. func TestDaoRawElecAVMessagesByVer(t *testing.T) {
  140. convey.Convey("RawElecAVMessages", t, func(ctx convey.C) {
  141. var (
  142. c = context.Background()
  143. payMIDs = []int64{27515316}
  144. avID = int64(123)
  145. ver = int64(201705)
  146. )
  147. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  148. dataMap, err := d.RawElecAVMessagesByVer(c, payMIDs, avID, ver)
  149. ctx.Convey("Then err should be nil.dataMap should not be nil.", func(ctx convey.C) {
  150. ctx.So(err, convey.ShouldBeNil)
  151. ctx.So(dataMap, convey.ShouldNotBeNil)
  152. })
  153. })
  154. })
  155. }
  156. func TestDaoRawElecAVMessages(t *testing.T) {
  157. convey.Convey("RawElecAVMessages", t, func(ctx convey.C) {
  158. var (
  159. c = context.Background()
  160. payMIDs = []int64{27515316}
  161. avID = int64(123)
  162. )
  163. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  164. dataMap, err := d.RawElecAVMessages(c, payMIDs, avID)
  165. ctx.Convey("Then err should be nil.dataMap should not be nil.", func(ctx convey.C) {
  166. ctx.So(err, convey.ShouldBeNil)
  167. ctx.So(dataMap, convey.ShouldNotBeNil)
  168. })
  169. })
  170. })
  171. }
  172. func TestDaoRawElecUPUserRank(t *testing.T) {
  173. convey.Convey("RawElecUPUserRank", t, func(ctx convey.C) {
  174. var (
  175. c = context.Background()
  176. upMID = int64(15555180)
  177. ver = int64(0)
  178. payAmount = int64(200)
  179. mtime = time.Now()
  180. )
  181. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  182. rank, err := d.RawElecUPUserRank(c, upMID, ver, payAmount, mtime)
  183. ctx.Convey("Then err should be nil.rank should not be nil.", func(ctx convey.C) {
  184. ctx.So(err, convey.ShouldBeNil)
  185. ctx.So(rank, convey.ShouldNotBeNil)
  186. })
  187. })
  188. })
  189. }
  190. func TestDaoRawElecAVUserRank(t *testing.T) {
  191. convey.Convey("RawElecAVUserRank", t, func(ctx convey.C) {
  192. var (
  193. c = context.Background()
  194. avID = int64(4052629)
  195. ver = int64(0)
  196. payAmount = int64(200)
  197. mtime = time.Now()
  198. )
  199. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  200. rank, err := d.RawElecAVUserRank(c, avID, ver, payAmount, mtime)
  201. ctx.Convey("Then err should be nil.rank should not be nil.", func(ctx convey.C) {
  202. ctx.So(err, convey.ShouldBeNil)
  203. ctx.So(rank, convey.ShouldNotBeNil)
  204. })
  205. })
  206. })
  207. }
  208. func TestDaoRawCountUPTotalElec(t *testing.T) {
  209. convey.Convey("RawCountUPTotalElec", t, func(ctx convey.C) {
  210. var (
  211. c = context.Background()
  212. upMID = int64(46333)
  213. )
  214. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  215. count, err := d.RawCountUPTotalElec(c, upMID)
  216. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  217. ctx.So(err, convey.ShouldBeNil)
  218. ctx.So(count, convey.ShouldNotBeNil)
  219. })
  220. })
  221. })
  222. }
  223. func TestDaoRawElecUserSettings(t *testing.T) {
  224. convey.Convey("RawElecUserSetting", t, func(ctx convey.C) {
  225. var (
  226. c = context.Background()
  227. id = 0
  228. limit = 10
  229. )
  230. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  231. value, maxID, err := d.RawElecUserSettings(c, id, limit)
  232. ctx.Convey("Then err should be nil.value should not be nil.", func(ctx convey.C) {
  233. ctx.So(err, convey.ShouldBeNil)
  234. ctx.So(maxID, convey.ShouldBeGreaterThan, 0)
  235. ctx.So(value, convey.ShouldNotBeNil)
  236. ctx.So(value, convey.ShouldHaveLength, 10)
  237. })
  238. })
  239. })
  240. }