mysql_test.go 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. package pendant
  2. import (
  3. "strconv"
  4. "testing"
  5. "time"
  6. "go-common/app/service/main/usersuit/model"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestPendantPendantGroupInfo(t *testing.T) {
  10. convey.Convey("PendantGroupInfo", t, func(ctx convey.C) {
  11. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  12. res, err := d.PendantGroupInfo(c)
  13. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  14. ctx.So(err, convey.ShouldBeNil)
  15. ctx.So(res, convey.ShouldNotBeNil)
  16. })
  17. })
  18. })
  19. }
  20. func TestPendantGroupByID(t *testing.T) {
  21. convey.Convey("GroupByID", t, func(ctx convey.C) {
  22. var (
  23. gid = int64(4)
  24. )
  25. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  26. res, err := d.GroupByID(c, gid)
  27. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  28. ctx.So(err, convey.ShouldBeNil)
  29. ctx.So(res, convey.ShouldNotBeNil)
  30. })
  31. })
  32. })
  33. }
  34. func TestPendantGIDRefPID(t *testing.T) {
  35. convey.Convey("GIDRefPID", t, func(ctx convey.C) {
  36. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  37. gidMap, pidMap, err := d.GIDRefPID(c)
  38. ctx.Convey("Then err should be nil.gidMap,pidMap should not be nil.", func(ctx convey.C) {
  39. ctx.So(err, convey.ShouldBeNil)
  40. ctx.So(pidMap, convey.ShouldNotBeNil)
  41. ctx.So(gidMap, convey.ShouldNotBeNil)
  42. })
  43. })
  44. })
  45. }
  46. func TestPendantPendantList(t *testing.T) {
  47. convey.Convey("PendantList", t, func(ctx convey.C) {
  48. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  49. res, err := d.PendantList(c)
  50. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  51. ctx.So(err, convey.ShouldBeNil)
  52. ctx.So(res, convey.ShouldNotBeNil)
  53. })
  54. })
  55. })
  56. }
  57. func TestPendantPendants(t *testing.T) {
  58. convey.Convey("Pendants", t, func(ctx convey.C) {
  59. var (
  60. pids = []int64{4}
  61. )
  62. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  63. res, err := d.Pendants(c, pids)
  64. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  65. ctx.So(err, convey.ShouldBeNil)
  66. ctx.So(res, convey.ShouldNotBeNil)
  67. })
  68. })
  69. })
  70. }
  71. func TestPendantPendantInfo(t *testing.T) {
  72. convey.Convey("PendantInfo", t, func(ctx convey.C) {
  73. var (
  74. pid = int64(4)
  75. )
  76. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  77. res, err := d.PendantInfo(c, pid)
  78. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  79. ctx.So(err, convey.ShouldBeNil)
  80. ctx.So(res, convey.ShouldNotBeNil)
  81. })
  82. })
  83. })
  84. }
  85. func TestPendantPendantPrice(t *testing.T) {
  86. convey.Convey("PendantPrice", t, func(ctx convey.C) {
  87. var (
  88. pid = int64(0)
  89. )
  90. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  91. res, err := d.PendantPrice(c, pid)
  92. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  93. ctx.So(err, convey.ShouldBeNil)
  94. ctx.So(res, convey.ShouldNotBeNil)
  95. })
  96. })
  97. })
  98. }
  99. func TestPendantgetOrderInfoSQL(t *testing.T) {
  100. convey.Convey("getOrderInfoSQL", t, func(ctx convey.C) {
  101. var (
  102. arg = &model.ArgOrderHistory{}
  103. tp = ""
  104. )
  105. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  106. sql, values := d.getOrderInfoSQL(c, arg, tp)
  107. ctx.Convey("Then sql,values should not be nil.", func(ctx convey.C) {
  108. ctx.So(values, convey.ShouldNotBeNil)
  109. ctx.So(sql, convey.ShouldNotBeNil)
  110. })
  111. })
  112. })
  113. }
  114. func TestPendantOrderInfo(t *testing.T) {
  115. convey.Convey("OrderInfo", t, func(ctx convey.C) {
  116. var (
  117. arg = &model.ArgOrderHistory{}
  118. )
  119. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  120. res, count, err := d.OrderInfo(c, arg)
  121. ctx.Convey("Then err should be nil.res,count should not be nil.", func(ctx convey.C) {
  122. ctx.So(err, convey.ShouldBeNil)
  123. ctx.So(count, convey.ShouldNotBeNil)
  124. ctx.So(res, convey.ShouldNotBeNil)
  125. })
  126. })
  127. })
  128. }
  129. func TestPendantOrderInfoByID(t *testing.T) {
  130. convey.Convey("OrderInfoByID", t, func(ctx convey.C) {
  131. var (
  132. orderID = ""
  133. )
  134. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  135. res, err := d.OrderInfoByID(c, orderID)
  136. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  137. ctx.So(err, convey.ShouldBeNil)
  138. ctx.So(res, convey.ShouldNotBeNil)
  139. })
  140. })
  141. })
  142. }
  143. func TestPendantAddOrderInfo(t *testing.T) {
  144. convey.Convey("AddOrderInfo", t, func(ctx convey.C) {
  145. var (
  146. arg = &model.PendantOrderInfo{Mid: 650454, OrderID: strconv.FormatInt(time.Now().Unix(), 10)}
  147. )
  148. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  149. id, err := d.AddOrderInfo(c, arg)
  150. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  151. ctx.So(err, convey.ShouldBeNil)
  152. ctx.So(id, convey.ShouldNotBeNil)
  153. })
  154. })
  155. })
  156. }
  157. func TestPendantTxAddOrderInfo(t *testing.T) {
  158. convey.Convey("TxAddOrderInfo", t, func(ctx convey.C) {
  159. var (
  160. arg = &model.PendantOrderInfo{Mid: 650454, OrderID: strconv.FormatInt(time.Now().UnixNano(), 10)}
  161. tx, _ = d.BeginTran(c)
  162. )
  163. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  164. id, err := d.TxAddOrderInfo(c, arg, tx)
  165. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  166. ctx.So(err, convey.ShouldBeNil)
  167. ctx.So(id, convey.ShouldNotBeNil)
  168. })
  169. })
  170. })
  171. }
  172. func TestPendantUpdateOrderInfo(t *testing.T) {
  173. convey.Convey("UpdateOrderInfo", t, func(ctx convey.C) {
  174. var (
  175. arg = &model.PendantOrderInfo{}
  176. )
  177. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  178. id, err := d.UpdateOrderInfo(c, arg)
  179. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  180. ctx.So(err, convey.ShouldBeNil)
  181. ctx.So(id, convey.ShouldNotBeNil)
  182. })
  183. })
  184. })
  185. }
  186. func TestPendantTxUpdateOrderInfo(t *testing.T) {
  187. convey.Convey("TxUpdateOrderInfo", t, func(ctx convey.C) {
  188. var (
  189. arg = &model.PendantOrderInfo{}
  190. tx, _ = d.BeginTran(c)
  191. )
  192. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  193. id, err := d.TxUpdateOrderInfo(c, arg, tx)
  194. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  195. ctx.So(err, convey.ShouldBeNil)
  196. ctx.So(id, convey.ShouldNotBeNil)
  197. })
  198. })
  199. })
  200. }
  201. func TestPendantPackageByMid(t *testing.T) {
  202. convey.Convey("PackageByMid", t, func(ctx convey.C) {
  203. var (
  204. mid = int64(650454)
  205. )
  206. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  207. res, err := d.PackageByMid(c, mid)
  208. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  209. ctx.So(err, convey.ShouldBeNil)
  210. ctx.So(res, convey.ShouldNotBeNil)
  211. })
  212. })
  213. })
  214. }
  215. func TestPendantPackageByID(t *testing.T) {
  216. convey.Convey("PackageByID", t, func(ctx convey.C) {
  217. var (
  218. mid = int64(650454)
  219. pid = int64(21)
  220. )
  221. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  222. res, err := d.PackageByID(c, mid, pid)
  223. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  224. ctx.So(err, convey.ShouldBeNil)
  225. ctx.So(res, convey.ShouldNotBeNil)
  226. })
  227. })
  228. })
  229. }
  230. func TestPendantEquipByMid(t *testing.T) {
  231. convey.Convey("EquipByMid", t, func(ctx convey.C) {
  232. var (
  233. mid = int64(88888929)
  234. no = int64(44)
  235. )
  236. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  237. res, noRow, err := d.EquipByMid(c, mid, no)
  238. ctx.Convey("Then err should be nil.res,noRow should not be nil.", func(ctx convey.C) {
  239. ctx.So(err, convey.ShouldBeNil)
  240. ctx.So(noRow, convey.ShouldNotBeNil)
  241. ctx.So(res, convey.ShouldNotBeNil)
  242. })
  243. })
  244. })
  245. }
  246. func TestPendantEquipByMids(t *testing.T) {
  247. convey.Convey("EquipByMids", t, func(ctx convey.C) {
  248. var (
  249. mids = []int64{650454}
  250. no = int64(0)
  251. )
  252. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  253. res, err := d.EquipByMids(c, mids, no)
  254. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  255. ctx.So(err, convey.ShouldBeNil)
  256. ctx.So(res, convey.ShouldNotBeNil)
  257. })
  258. })
  259. })
  260. }
  261. func TestPendantAddEquip(t *testing.T) {
  262. convey.Convey("AddEquip", t, func(ctx convey.C) {
  263. var (
  264. arg = &model.PendantEquip{}
  265. )
  266. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  267. n, err := d.AddEquip(c, arg)
  268. ctx.Convey("Then err should be nil.n should not be nil.", func(ctx convey.C) {
  269. ctx.So(err, convey.ShouldBeNil)
  270. ctx.So(n, convey.ShouldNotBeNil)
  271. })
  272. })
  273. })
  274. }
  275. func TestPendantTxUpdatePackageInfo(t *testing.T) {
  276. convey.Convey("TxUpdatePackageInfo", t, func(ctx convey.C) {
  277. var (
  278. arg = &model.PendantPackage{Mid: 88888929, Pid: 2, Status: 1}
  279. tx, _ = d.BeginTran(c)
  280. )
  281. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  282. n, err := d.TxUpdatePackageInfo(c, arg, tx)
  283. ctx.Convey("Then err should be nil.n should not be nil.", func(ctx convey.C) {
  284. ctx.So(err, convey.ShouldBeNil)
  285. ctx.So(n, convey.ShouldNotBeNil)
  286. })
  287. })
  288. })
  289. }
  290. func TestPendantCheckPackageExpire(t *testing.T) {
  291. convey.Convey("CheckPackageExpire", t, func(ctx convey.C) {
  292. var (
  293. mid = int64(650454)
  294. expires = int64(2147483647)
  295. )
  296. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  297. rows, err := d.CheckPackageExpire(c, mid, expires)
  298. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  299. ctx.So(err, convey.ShouldBeNil)
  300. ctx.So(rows, convey.ShouldNotBeNil)
  301. })
  302. })
  303. })
  304. }
  305. func TestPendantBeginTran(t *testing.T) {
  306. convey.Convey("BeginTran", t, func(ctx convey.C) {
  307. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  308. res, err := d.BeginTran(c)
  309. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  310. ctx.So(err, convey.ShouldBeNil)
  311. ctx.So(res, convey.ShouldNotBeNil)
  312. })
  313. })
  314. })
  315. }
  316. func TestPendantTxAddPackage(t *testing.T) {
  317. convey.Convey("TxAddPackage", t, func(ctx convey.C) {
  318. var (
  319. arg = &model.PendantPackage{Mid: time.Now().Unix(), Pid: 4}
  320. tx, _ = d.BeginTran(c)
  321. )
  322. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  323. id, err := d.TxAddPackage(c, arg, tx)
  324. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  325. ctx.So(err, convey.ShouldBeNil)
  326. ctx.So(id, convey.ShouldNotBeNil)
  327. })
  328. })
  329. })
  330. }
  331. func TestPendantTxAddHistory(t *testing.T) {
  332. convey.Convey("TxAddHistory", t, func(ctx convey.C) {
  333. var (
  334. arg = &model.PendantHistory{}
  335. tx, _ = d.BeginTran(c)
  336. )
  337. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  338. id, err := d.TxAddHistory(c, arg, tx)
  339. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  340. ctx.So(err, convey.ShouldBeNil)
  341. ctx.So(id, convey.ShouldNotBeNil)
  342. })
  343. })
  344. })
  345. }