resource_test.go 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "go-common/app/service/main/vip/model"
  7. xtime "go-common/library/time"
  8. "github.com/smartystreets/goconvey/convey"
  9. )
  10. func TestDaoSelNewResourcePool(t *testing.T) {
  11. var (
  12. c = context.TODO()
  13. id = int64(0)
  14. )
  15. convey.Convey("SelNewResourcePool", t, func(ctx convey.C) {
  16. _, err := d.SelNewResourcePool(c, id)
  17. ctx.Convey("Error should be nil", func(ctx convey.C) {
  18. ctx.So(err, convey.ShouldBeNil)
  19. })
  20. })
  21. }
  22. func TestDaoSelNewBusiness(t *testing.T) {
  23. var (
  24. c = context.TODO()
  25. id = int64(0)
  26. )
  27. convey.Convey("SelNewBusiness", t, func(ctx convey.C) {
  28. _, err := d.SelNewBusiness(c, id)
  29. ctx.Convey("Error should be nil", func(ctx convey.C) {
  30. ctx.So(err, convey.ShouldBeNil)
  31. })
  32. })
  33. }
  34. func TestDaoSelNewBusinessByAppkey(t *testing.T) {
  35. var (
  36. c = context.TODO()
  37. appkey = ""
  38. )
  39. convey.Convey("SelNewBusinessByAppkey", t, func(ctx convey.C) {
  40. _, err := d.SelNewBusinessByAppkey(c, appkey)
  41. ctx.Convey("Error should be nil", func(ctx convey.C) {
  42. ctx.So(err, convey.ShouldBeNil)
  43. })
  44. })
  45. }
  46. func TestDaoSelCode(t *testing.T) {
  47. var (
  48. c = context.TODO()
  49. codeStr = ""
  50. )
  51. convey.Convey("SelCode", t, func(ctx convey.C) {
  52. code, err := d.SelCode(c, codeStr)
  53. ctx.Convey("Error should be nil", func(ctx convey.C) {
  54. ctx.So(err, convey.ShouldBeNil)
  55. })
  56. ctx.Convey("code should not be nil", func(ctx convey.C) {
  57. ctx.So(code, convey.ShouldNotBeNil)
  58. })
  59. })
  60. }
  61. func TestDaoSelCodes(t *testing.T) {
  62. var (
  63. c = context.TODO()
  64. codes []string
  65. )
  66. convey.Convey("SelCodes", t, func(ctx convey.C) {
  67. _, err := d.SelCodes(c, codes)
  68. ctx.Convey("Error should be nil", func(ctx convey.C) {
  69. ctx.So(err, convey.ShouldBeNil)
  70. })
  71. })
  72. }
  73. func TestDaoSelBatchCode(t *testing.T) {
  74. var (
  75. c = context.TODO()
  76. id = int64(0)
  77. )
  78. convey.Convey("SelBatchCode", t, func(ctx convey.C) {
  79. _, err := d.SelBatchCode(c, id)
  80. ctx.Convey("Error should be nil", func(ctx convey.C) {
  81. ctx.So(err, convey.ShouldBeNil)
  82. })
  83. })
  84. }
  85. func TestDaoSelBatchCodes(t *testing.T) {
  86. var (
  87. c = context.TODO()
  88. ids []int64
  89. )
  90. convey.Convey("SelBatchCodes", t, func(ctx convey.C) {
  91. _, err := d.SelBatchCodes(c, ids)
  92. ctx.Convey("Error should be nil", func(ctx convey.C) {
  93. ctx.So(err, convey.ShouldBeNil)
  94. })
  95. })
  96. }
  97. func TestDaoSelBatchCodesByBisID(t *testing.T) {
  98. var (
  99. c = context.TODO()
  100. bisID = int64(0)
  101. )
  102. convey.Convey("SelBatchCodesByBisID", t, func(ctx convey.C) {
  103. _, err := d.SelBatchCodesByBisID(c, bisID)
  104. ctx.Convey("Error should be nil", func(ctx convey.C) {
  105. ctx.So(err, convey.ShouldBeNil)
  106. })
  107. })
  108. }
  109. func TestDaoSelCodeOpened(t *testing.T) {
  110. var (
  111. c = context.TODO()
  112. bisIDs = []int64{1}
  113. arg = &model.ArgCodeOpened{}
  114. )
  115. convey.Convey("SelCodeOpened", t, func(ctx convey.C) {
  116. _, err := d.SelCodeOpened(c, bisIDs, arg)
  117. ctx.Convey("Error should be nil", func(ctx convey.C) {
  118. ctx.So(err, convey.ShouldBeNil)
  119. })
  120. })
  121. }
  122. func TestDaoTxUpdateCode(t *testing.T) {
  123. var (
  124. c = context.TODO()
  125. id = int64(0)
  126. mid = int64(0)
  127. useTime = xtime.Time(time.Now().Unix())
  128. )
  129. convey.Convey("TxUpdateCode", t, func(ctx convey.C) {
  130. tx, err := d.StartTx(c)
  131. ctx.Convey("Tx Error should be nil", func(ctx convey.C) {
  132. ctx.So(err, convey.ShouldBeNil)
  133. })
  134. defer tx.Commit()
  135. eff, err := d.TxUpdateCode(tx, id, mid, useTime)
  136. ctx.Convey("Error should be nil", func(ctx convey.C) {
  137. ctx.So(err, convey.ShouldBeNil)
  138. })
  139. ctx.Convey("eff should not be nil", func(ctx convey.C) {
  140. ctx.So(eff, convey.ShouldNotBeNil)
  141. })
  142. })
  143. }
  144. func TestDaoTxUpdateCodeStatus(t *testing.T) {
  145. var (
  146. c = context.TODO()
  147. id = int64(0)
  148. status = int8(0)
  149. )
  150. convey.Convey("TxUpdateCodeStatus", t, func(ctx convey.C) {
  151. tx, err := d.StartTx(c)
  152. ctx.Convey("Tx Error should be nil", func(ctx convey.C) {
  153. ctx.So(err, convey.ShouldBeNil)
  154. })
  155. defer tx.Commit()
  156. eff, err := d.TxUpdateCodeStatus(tx, id, status)
  157. ctx.Convey("Error should be nil", func(ctx convey.C) {
  158. ctx.So(err, convey.ShouldBeNil)
  159. })
  160. ctx.Convey("eff should not be nil", func(ctx convey.C) {
  161. ctx.So(eff, convey.ShouldNotBeNil)
  162. })
  163. })
  164. }
  165. func TestDaoTxUpdateBatchCode(t *testing.T) {
  166. var (
  167. c = context.TODO()
  168. id = int64(0)
  169. sc = int32(0)
  170. )
  171. convey.Convey("TxUpdateBatchCode", t, func(ctx convey.C) {
  172. tx, err := d.StartTx(c)
  173. ctx.Convey("Tx Error should be nil", func(ctx convey.C) {
  174. ctx.So(err, convey.ShouldBeNil)
  175. })
  176. defer tx.Commit()
  177. eff, err := d.TxUpdateBatchCode(tx, id, sc)
  178. ctx.Convey("Error should be nil", func(ctx convey.C) {
  179. ctx.So(err, convey.ShouldBeNil)
  180. })
  181. ctx.Convey("eff should not be nil", func(ctx convey.C) {
  182. ctx.So(eff, convey.ShouldNotBeNil)
  183. })
  184. })
  185. }
  186. func TestDaoSelCodesByBMid(t *testing.T) {
  187. var (
  188. c = context.TODO()
  189. mid = int64(0)
  190. )
  191. convey.Convey("SelCodesByBMid", t, func(ctx convey.C) {
  192. cs, err := d.SelCodesByBMid(c, mid)
  193. ctx.Convey("Error should be nil", func(ctx convey.C) {
  194. ctx.So(err, convey.ShouldBeNil)
  195. })
  196. ctx.Convey("cs should not be nil", func(ctx convey.C) {
  197. ctx.So(cs, convey.ShouldNotBeNil)
  198. })
  199. })
  200. }
  201. func TestDaoSelActives(t *testing.T) {
  202. var (
  203. c = context.TODO()
  204. relations []string
  205. )
  206. convey.Convey("SelActives", t, func(ctx convey.C) {
  207. _, err := d.SelActives(c, relations)
  208. ctx.Convey("Error should be nil", func(ctx convey.C) {
  209. ctx.So(err, convey.ShouldBeNil)
  210. })
  211. })
  212. }
  213. func TestDaoSelBatchCount(t *testing.T) {
  214. var (
  215. c = context.TODO()
  216. batchCodeID int64 = 1
  217. mid int64 = 1001
  218. )
  219. convey.Convey("sel batch count", t, func(ctx convey.C) {
  220. _, err := d.SelBatchCount(c, batchCodeID, mid)
  221. ctx.Convey("Error should be nil", func(ctx convey.C) {
  222. ctx.So(err, convey.ShouldBeNil)
  223. })
  224. })
  225. }