pendant_test.go 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. package dao
  2. import (
  3. "context"
  4. "math/rand"
  5. "testing"
  6. "go-common/app/admin/main/usersuit/model"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. func Test_AddPendantGroup(t *testing.T) {
  10. Convey("return someting", t, func() {
  11. pg := &model.PendantGroup{
  12. Name: "dasdasd",
  13. Rank: 22,
  14. }
  15. gid, err := d.AddPendantGroup(context.Background(), pg)
  16. So(err, ShouldBeNil)
  17. So(gid, ShouldNotBeNil)
  18. })
  19. }
  20. func Test_TxAddPendantGroupRef(t *testing.T) {
  21. Convey("return someting", t, func() {
  22. pr := &model.PendantGroupRef{
  23. GID: 11,
  24. PID: int64(rand.Int31()),
  25. }
  26. tx, err := d.BeginTran(context.Background())
  27. So(err, ShouldBeNil)
  28. effect, err := d.TxAddPendantGroupRef(tx, pr)
  29. So(err, ShouldBeNil)
  30. defer func() {
  31. if err != nil || effect == 0 {
  32. tx.Rollback()
  33. return
  34. }
  35. tx.Commit()
  36. }()
  37. So(err, ShouldBeNil)
  38. })
  39. }
  40. func Test_TxAddPendantInfo(t *testing.T) {
  41. Convey("return someting", t, func() {
  42. pi := &model.PendantInfo{
  43. Name: "dasdasdsads",
  44. Image: "dasdds",
  45. ImageModel: "xxsss",
  46. Rank: 11,
  47. }
  48. tx, err := d.BeginTran(context.Background())
  49. if err != nil {
  50. So(err, ShouldBeNil)
  51. }
  52. id, err := d.TxAddPendantInfo(tx, pi)
  53. if err != nil {
  54. So(err, ShouldBeNil)
  55. }
  56. defer func() {
  57. if err != nil || id == 0 {
  58. tx.Rollback()
  59. return
  60. }
  61. tx.Commit()
  62. }()
  63. So(err, ShouldBeNil)
  64. })
  65. }
  66. func Test_TxAddPendantPrices(t *testing.T) {
  67. Convey("return someting", t, func() {
  68. pp := &model.PendantPrice{
  69. PID: 22,
  70. TP: 1,
  71. Price: 22,
  72. }
  73. tx, err := d.BeginTran(context.Background())
  74. if err != nil {
  75. So(err, ShouldBeNil)
  76. }
  77. effect, err := d.TxAddPendantPrices(tx, pp)
  78. if err != nil {
  79. So(err, ShouldBeNil)
  80. }
  81. defer func() {
  82. if err != nil || effect == 0 {
  83. tx.Rollback()
  84. return
  85. }
  86. tx.Commit()
  87. }()
  88. So(err, ShouldBeNil)
  89. })
  90. }
  91. func Test_AddPendantPKG(t *testing.T) {
  92. Convey("return someting", t, func() {
  93. pkg := &model.PendantPKG{
  94. UID: int64(rand.Int31()),
  95. PID: 11,
  96. Expires: 12312323,
  97. }
  98. _, err := d.AddPendantPKG(context.Background(), pkg)
  99. So(err, ShouldBeNil)
  100. })
  101. }
  102. func Test_TxAddPendantPKGs(t *testing.T) {
  103. uid := int64(rand.Int31())
  104. Convey("return someting", t, func() {
  105. var pkgs []*model.PendantPKG
  106. pkgs = append(pkgs, &model.PendantPKG{UID: uid, PID: 11, Expires: 12312323}, &model.PendantPKG{UID: uid, PID: 22, Expires: 12312323})
  107. tx, err := d.BeginTran(context.Background())
  108. if err != nil {
  109. So(err, ShouldBeNil)
  110. }
  111. effect, err := d.TxAddPendantPKGs(tx, pkgs)
  112. if err != nil {
  113. So(err, ShouldBeNil)
  114. }
  115. defer func() {
  116. if err != nil || effect == 0 {
  117. tx.Rollback()
  118. return
  119. }
  120. tx.Commit()
  121. }()
  122. So(err, ShouldBeNil)
  123. })
  124. }
  125. func Test_AddPendantEquip(t *testing.T) {
  126. Convey("return someting", t, func() {
  127. pkg := &model.PendantPKG{
  128. UID: 22,
  129. PID: 11,
  130. Expires: 12312323,
  131. }
  132. _, err := d.AddPendantEquip(context.Background(), pkg)
  133. So(err, ShouldBeNil)
  134. })
  135. }
  136. func Test_AddPendantOperLog(t *testing.T) {
  137. Convey("return someting", t, func() {
  138. _, err := d.AddPendantOperLog(context.Background(), 1, []int64{1}, 1, "sdsadasd")
  139. So(err, ShouldBeNil)
  140. })
  141. }
  142. func Test_TxUpPendantGroupRef(t *testing.T) {
  143. Convey("return someting", t, func() {
  144. tx, err := d.BeginTran(context.Background())
  145. if err != nil {
  146. So(err, ShouldBeNil)
  147. }
  148. effect, err := d.TxUpPendantGroupRef(tx, 22, 11)
  149. if err != nil {
  150. So(err, ShouldBeNil)
  151. }
  152. defer func() {
  153. if err != nil || effect == 0 {
  154. tx.Rollback()
  155. return
  156. }
  157. tx.Commit()
  158. }()
  159. So(err, ShouldBeNil)
  160. })
  161. }
  162. func Test_TxUpPendantPKGs(t *testing.T) {
  163. Convey("return someting", t, func() {
  164. var pkgs []*model.PendantPKG
  165. pkgs = append(pkgs, &model.PendantPKG{UID: 22, PID: 11, Expires: 12312323}, &model.PendantPKG{UID: 11, PID: 22, Expires: 12312323})
  166. tx, err := d.BeginTran(context.Background())
  167. if err != nil {
  168. So(err, ShouldBeNil)
  169. }
  170. effect, err := d.TxUpPendantPKGs(tx, pkgs)
  171. if err != nil {
  172. So(err, ShouldBeNil)
  173. }
  174. defer func() {
  175. if err != nil || effect == 0 {
  176. tx.Rollback()
  177. return
  178. }
  179. tx.Commit()
  180. }()
  181. So(err, ShouldBeNil)
  182. })
  183. }
  184. func Test_UpPendantGroup(t *testing.T) {
  185. Convey("return someting", t, func() {
  186. pg := &model.PendantGroup{
  187. Name: "weqweqw",
  188. Rank: 2,
  189. Status: 1,
  190. ID: 22,
  191. }
  192. _, err := d.UpPendantGroup(context.Background(), pg)
  193. So(err, ShouldBeNil)
  194. })
  195. }
  196. func Test_UpPendantGroupStatus(t *testing.T) {
  197. Convey("return someting", t, func() {
  198. _, err := d.UpPendantGroupStatus(context.Background(), 22, 1)
  199. So(err, ShouldBeNil)
  200. })
  201. }
  202. func Test_TxUpPendantInfo(t *testing.T) {
  203. Convey("return someting", t, func() {
  204. pi := &model.PendantInfo{
  205. Name: "dasdasdsads",
  206. Image: "dasdds",
  207. ImageModel: "xxsss",
  208. Rank: 11,
  209. ID: 22,
  210. }
  211. tx, err := d.BeginTran(context.Background())
  212. if err != nil {
  213. So(err, ShouldBeNil)
  214. }
  215. effect, err := d.TxUpPendantInfo(tx, pi)
  216. if err != nil {
  217. So(err, ShouldBeNil)
  218. }
  219. defer func() {
  220. if err != nil || effect == 0 {
  221. tx.Rollback()
  222. return
  223. }
  224. tx.Commit()
  225. }()
  226. So(err, ShouldBeNil)
  227. })
  228. }
  229. func Test_UpPendantInfoStatus(t *testing.T) {
  230. Convey("return someting", t, func() {
  231. _, err := d.UpPendantInfoStatus(context.Background(), 22, 1)
  232. So(err, ShouldBeNil)
  233. })
  234. }
  235. func Test_PendantInfoAll(t *testing.T) {
  236. Convey("return someting", t, func() {
  237. _, _, err := d.PendantInfoAll(context.Background(), 1, 2)
  238. So(err, ShouldBeNil)
  239. })
  240. }
  241. func Test_PendantGroupIDs(t *testing.T) {
  242. Convey("return someting", t, func() {
  243. _, err := d.PendantGroupIDs(context.Background(), []int64{11, 22})
  244. So(err, ShouldBeNil)
  245. })
  246. }
  247. func Test_PendantGroupID(t *testing.T) {
  248. Convey("return someting", t, func() {
  249. _, err := d.PendantGroupID(context.Background(), 12)
  250. So(err, ShouldBeNil)
  251. })
  252. }
  253. func Test_PendantInfoIDs(t *testing.T) {
  254. Convey("return someting", t, func() {
  255. _, _, err := d.PendantInfoIDs(context.Background(), []int64{11, 22})
  256. So(err, ShouldBeNil)
  257. })
  258. }
  259. func Test_PendantPriceIDs(t *testing.T) {
  260. Convey("return someting", t, func() {
  261. ppm, err := d.PendantPriceIDs(context.Background(), []int64{11, 22})
  262. So(err, ShouldBeNil)
  263. So(ppm, ShouldNotBeNil)
  264. })
  265. }
  266. func Test_PendantGroupRefRanks(t *testing.T) {
  267. Convey("return someting", t, func() {
  268. _, err := d.PendantGroupRefRanks(context.Background(), 1, 2)
  269. So(err, ShouldBeNil)
  270. })
  271. }
  272. func Test_PendantGroupPIDs(t *testing.T) {
  273. Convey("return someting", t, func() {
  274. _, err := d.PendantGroupPIDs(context.Background(), 11, 1, 2)
  275. So(err, ShouldBeNil)
  276. })
  277. }
  278. func Test_PendantInfoID(t *testing.T) {
  279. Convey("return someting", t, func() {
  280. pi, err := d.PendantInfoID(context.Background(), 11)
  281. So(err, ShouldBeNil)
  282. So(pi, ShouldNotBeNil)
  283. })
  284. }
  285. func Test_PendantInfoAllOnSale(t *testing.T) {
  286. Convey("return someting", t, func() {
  287. _, err := d.PendantInfoAllNoPage(context.Background())
  288. So(err, ShouldBeNil)
  289. })
  290. }
  291. func Test_CountOrderHistory(t *testing.T) {
  292. Convey("return someting", t, func() {
  293. arg := &model.ArgPendantOrder{}
  294. _, err := d.CountOrderHistory(context.Background(), arg)
  295. So(err, ShouldBeNil)
  296. })
  297. }
  298. func Test_OrderHistorys(t *testing.T) {
  299. Convey("return someting", t, func() {
  300. arg := &model.ArgPendantOrder{}
  301. _, _, err := d.OrderHistorys(context.Background(), arg)
  302. So(err, ShouldBeNil)
  303. })
  304. }
  305. func Test_PendantPKGs(t *testing.T) {
  306. Convey("return someting", t, func() {
  307. _, err := d.PendantPKGs(context.Background(), 112)
  308. So(err, ShouldBeNil)
  309. })
  310. }
  311. func Test_PendantPKGUIDs(t *testing.T) {
  312. Convey("return someting", t, func() {
  313. _, err := d.PendantPKGUIDs(context.Background(), []int64{11, 22}, 112)
  314. So(err, ShouldBeNil)
  315. })
  316. }
  317. func Test_PendantPKG(t *testing.T) {
  318. Convey("return someting", t, func() {
  319. _, err := d.PendantPKG(context.Background(), 11, 112)
  320. So(err, ShouldBeNil)
  321. })
  322. }
  323. func Test_PendantEquipUID(t *testing.T) {
  324. Convey("return someting", t, func() {
  325. _, err := d.PendantEquipUID(context.Background(), 11)
  326. So(err, ShouldBeNil)
  327. })
  328. }
  329. func Test_PendantOperLog(t *testing.T) {
  330. Convey("return someting", t, func() {
  331. _, _, err := d.PendantOperLog(context.Background(), 1, 2)
  332. So(err, ShouldBeNil)
  333. })
  334. }
  335. func Test_PendantOperationLogTotal(t *testing.T) {
  336. Convey("return someting", t, func() {
  337. total, err := d.PendantOperationLogTotal(context.Background())
  338. So(err, ShouldBeNil)
  339. So(total, ShouldNotBeNil)
  340. })
  341. }