mysql_test.go 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308
  1. package dao
  2. import (
  3. "context"
  4. "fmt"
  5. "go-common/app/job/main/ugcpay/model"
  6. "math/rand"
  7. "testing"
  8. "time"
  9. "github.com/smartystreets/goconvey/convey"
  10. )
  11. func TestDaoCountPaidOrderUser(t *testing.T) {
  12. convey.Convey("CountPaidOrderUser", t, func(ctx convey.C) {
  13. var (
  14. c = context.Background()
  15. beginTime = time.Now()
  16. endTime = time.Now()
  17. )
  18. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  19. count, err := d.CountPaidOrderUser(c, beginTime, endTime)
  20. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  21. ctx.So(err, convey.ShouldBeNil)
  22. ctx.So(count, convey.ShouldNotBeNil)
  23. })
  24. })
  25. })
  26. }
  27. func TestDaoCountRefundedOrderUser(t *testing.T) {
  28. convey.Convey("CountRefundedOrderUser", t, func(ctx convey.C) {
  29. var (
  30. c = context.Background()
  31. beginTime = time.Now()
  32. endTime = time.Now()
  33. )
  34. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  35. count, err := d.CountRefundedOrderUser(c, beginTime, endTime)
  36. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  37. ctx.So(err, convey.ShouldBeNil)
  38. ctx.So(count, convey.ShouldNotBeNil)
  39. })
  40. })
  41. })
  42. }
  43. func TestDaoCountDailyBillByVer(t *testing.T) {
  44. convey.Convey("CountDailyBillByVer", t, func(ctx convey.C) {
  45. var (
  46. c = context.Background()
  47. ver = int64(20181030)
  48. )
  49. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  50. count, err := d.CountDailyBillByVer(c, ver)
  51. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  52. ctx.So(err, convey.ShouldBeNil)
  53. ctx.So(count, convey.ShouldNotBeNil)
  54. })
  55. })
  56. })
  57. }
  58. func TestDaoCountDailyBillByMonthVer(t *testing.T) {
  59. convey.Convey("CountDailyBillByMonthVer", t, func(ctx convey.C) {
  60. var (
  61. c = context.Background()
  62. monthVer = int64(20181030)
  63. )
  64. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  65. count, err := d.CountDailyBillByMonthVer(c, monthVer)
  66. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  67. ctx.So(err, convey.ShouldBeNil)
  68. ctx.So(count, convey.ShouldNotBeNil)
  69. })
  70. })
  71. })
  72. }
  73. func TestDaoCountMonthlyBillByVer(t *testing.T) {
  74. convey.Convey("CountMonthlyBillByVer", t, func(ctx convey.C) {
  75. var (
  76. c = context.Background()
  77. ver = int64(201811)
  78. )
  79. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  80. count, err := d.CountMonthlyBillByVer(c, ver)
  81. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  82. ctx.So(err, convey.ShouldBeNil)
  83. ctx.So(count, convey.ShouldNotBeNil)
  84. })
  85. })
  86. })
  87. }
  88. func TestDaoInsertLogTask(t *testing.T) {
  89. convey.Convey("InsertLogTask", t, func(ctx convey.C) {
  90. var (
  91. c = context.Background()
  92. data = &model.LogTask{
  93. Name: fmt.Sprintf("ut_%d", time.Now().Unix()),
  94. Expect: 233,
  95. }
  96. )
  97. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  98. id, err := d.InsertLogTask(c, data)
  99. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  100. ctx.So(err, convey.ShouldBeNil)
  101. ctx.So(id, convey.ShouldNotBeNil)
  102. })
  103. })
  104. })
  105. }
  106. func TestDaoLogTask(t *testing.T) {
  107. convey.Convey("LogTask", t, func(ctx convey.C) {
  108. var (
  109. c = context.Background()
  110. name = "ut"
  111. )
  112. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  113. data, err := d.LogTask(c, name)
  114. ctx.Convey("Then err should be nil.data should not be nil.", func(ctx convey.C) {
  115. ctx.So(err, convey.ShouldBeNil)
  116. ctx.So(data, convey.ShouldNotBeNil)
  117. })
  118. })
  119. })
  120. }
  121. func TestDaoTXIncrLogTaskSuccess(t *testing.T) {
  122. convey.Convey("TXIncrLogTaskSuccess", t, func(ctx convey.C) {
  123. var (
  124. c = context.Background()
  125. tx, _ = d.BeginTran(c)
  126. name = "ut"
  127. )
  128. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  129. rows, err := d.TXIncrLogTaskSuccess(c, tx, name)
  130. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  131. ctx.So(err, convey.ShouldBeNil)
  132. ctx.So(rows, convey.ShouldNotBeNil)
  133. })
  134. })
  135. ctx.Reset(func() {
  136. tx.Commit()
  137. })
  138. })
  139. }
  140. func TestDaoIncrLogTaskFailure(t *testing.T) {
  141. convey.Convey("IncrLogTaskFailure", t, func(ctx convey.C) {
  142. var (
  143. c = context.Background()
  144. name = "ut"
  145. )
  146. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  147. rows, err := d.IncrLogTaskFailure(c, name)
  148. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  149. ctx.So(err, convey.ShouldBeNil)
  150. ctx.So(rows, convey.ShouldNotBeNil)
  151. })
  152. })
  153. })
  154. }
  155. func TestDaoAsset(t *testing.T) {
  156. convey.Convey("Asset", t, func(ctx convey.C) {
  157. var (
  158. c = context.Background()
  159. oid = int64(2333)
  160. otype = "archive"
  161. currency = "bp"
  162. )
  163. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  164. data, err := d.Asset(c, oid, otype, currency)
  165. ctx.Convey("Then err should be nil.data should not be nil.", func(ctx convey.C) {
  166. ctx.So(err, convey.ShouldBeNil)
  167. ctx.So(data, convey.ShouldNotBeNil)
  168. })
  169. })
  170. })
  171. }
  172. func TestDaoSumPaidOrderUserRealFee(t *testing.T) {
  173. convey.Convey("SumPaidOrderUserRealFee", t, func(ctx convey.C) {
  174. var (
  175. c = context.Background()
  176. beginTime = time.Now()
  177. endTime = time.Now()
  178. )
  179. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  180. sum, err := d.SumPaidOrderUserRealFee(c, beginTime, endTime)
  181. ctx.Convey("Then err should be nil.sum should not be nil.", func(ctx convey.C) {
  182. ctx.So(err, convey.ShouldBeNil)
  183. ctx.So(sum, convey.ShouldNotBeNil)
  184. })
  185. })
  186. })
  187. }
  188. func TestDaoSumRefundedOrderUserRealFee(t *testing.T) {
  189. convey.Convey("SumRefundedOrderUserRealFee", t, func(ctx convey.C) {
  190. var (
  191. c = context.Background()
  192. beginTime = time.Now()
  193. endTime = time.Now()
  194. )
  195. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  196. sum, err := d.SumRefundedOrderUserRealFee(c, beginTime, endTime)
  197. ctx.Convey("Then err should be nil.sum should not be nil.", func(ctx convey.C) {
  198. ctx.So(err, convey.ShouldBeNil)
  199. ctx.So(sum, convey.ShouldNotBeNil)
  200. })
  201. })
  202. })
  203. }
  204. func TestDaoSumDailyBill(t *testing.T) {
  205. convey.Convey("SumDailyBill", t, func(ctx convey.C) {
  206. var (
  207. c = context.Background()
  208. ver = int64(20181030)
  209. )
  210. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  211. sumIn, sumOut, err := d.SumDailyBill(c, ver)
  212. ctx.Convey("Then err should be nil.sumIn,sumOut should not be nil.", func(ctx convey.C) {
  213. ctx.So(err, convey.ShouldBeNil)
  214. ctx.So(sumOut, convey.ShouldNotBeNil)
  215. ctx.So(sumIn, convey.ShouldNotBeNil)
  216. })
  217. })
  218. })
  219. }
  220. func TestDaoMinIDOrderPaid(t *testing.T) {
  221. convey.Convey("MinIDOrderPaid", t, func(ctx convey.C) {
  222. var (
  223. c = context.Background()
  224. beginTime = time.Now()
  225. )
  226. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  227. minID, err := d.MinIDOrderPaid(c, beginTime)
  228. ctx.Convey("Then err should be nil.minID should not be nil.", func(ctx convey.C) {
  229. ctx.So(err, convey.ShouldBeNil)
  230. ctx.So(minID, convey.ShouldNotBeNil)
  231. })
  232. })
  233. })
  234. }
  235. func TestDaoOrderPaidList(t *testing.T) {
  236. convey.Convey("OrderPaidList", t, func(ctx convey.C) {
  237. var (
  238. c = context.Background()
  239. beginTime = time.Now()
  240. endTime = time.Now()
  241. fromID = int64(0)
  242. limit = int(10)
  243. )
  244. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  245. maxID, _, err := d.OrderPaidList(c, beginTime, endTime, fromID, limit)
  246. ctx.Convey("Then err should be nil.maxID,data should not be nil.", func(ctx convey.C) {
  247. ctx.So(err, convey.ShouldBeNil)
  248. // ctx.So(data, convey.ShouldNotBeNil)
  249. ctx.So(maxID, convey.ShouldNotBeNil)
  250. })
  251. })
  252. })
  253. }
  254. func TestDaoMinIDOrderRefunded(t *testing.T) {
  255. convey.Convey("MinIDOrderRefunded", t, func(ctx convey.C) {
  256. var (
  257. c = context.Background()
  258. beginTime = time.Now()
  259. )
  260. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  261. minID, err := d.MinIDOrderRefunded(c, beginTime)
  262. ctx.Convey("Then err should be nil.minID should not be nil.", func(ctx convey.C) {
  263. ctx.So(err, convey.ShouldBeNil)
  264. ctx.So(minID, convey.ShouldNotBeNil)
  265. })
  266. })
  267. })
  268. }
  269. func TestDaoOrderRefundedList(t *testing.T) {
  270. convey.Convey("OrderRefundedList", t, func(ctx convey.C) {
  271. var (
  272. c = context.Background()
  273. beginTime = time.Now()
  274. endTime = time.Now()
  275. fromID = int64(0)
  276. limit = int(10)
  277. )
  278. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  279. maxID, _, err := d.OrderRefundedList(c, beginTime, endTime, fromID, limit)
  280. ctx.Convey("Then err should be nil.maxID,data should not be nil.", func(ctx convey.C) {
  281. ctx.So(err, convey.ShouldBeNil)
  282. // ctx.So(data, convey.ShouldNotBeNil)
  283. ctx.So(maxID, convey.ShouldNotBeNil)
  284. })
  285. })
  286. })
  287. }
  288. func TestDaoTXUpdateOrder(t *testing.T) {
  289. convey.Convey("TXUpdateOrder", t, func(ctx convey.C) {
  290. var (
  291. c = context.Background()
  292. tx, _ = d.BeginTran(c)
  293. order = &model.Order{}
  294. )
  295. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  296. rows, err := d.TXUpdateOrder(c, tx, order)
  297. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  298. ctx.So(err, convey.ShouldBeNil)
  299. ctx.So(rows, convey.ShouldNotBeNil)
  300. })
  301. })
  302. ctx.Reset(func() {
  303. tx.Commit()
  304. })
  305. })
  306. }
  307. func TestDaoTXInsertOrderUserLog(t *testing.T) {
  308. convey.Convey("TXInsertOrderUserLog", t, func(ctx convey.C) {
  309. var (
  310. c = context.Background()
  311. tx, _ = d.BeginTran(c)
  312. data = &model.LogOrder{
  313. OrderID: "ut",
  314. Desc: "ut",
  315. }
  316. )
  317. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  318. id, err := d.TXInsertOrderUserLog(c, tx, data)
  319. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  320. ctx.So(err, convey.ShouldBeNil)
  321. ctx.So(id, convey.ShouldNotBeNil)
  322. })
  323. })
  324. ctx.Reset(func() {
  325. tx.Commit()
  326. })
  327. })
  328. }
  329. func TestDaoMinIDDailyBillByVer(t *testing.T) {
  330. convey.Convey("MinIDDailyBillByVer", t, func(ctx convey.C) {
  331. var (
  332. c = context.Background()
  333. ver = int64(20181030)
  334. )
  335. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  336. minID, err := d.MinIDDailyBillByVer(c, ver)
  337. ctx.Convey("Then err should be nil.minID should not be nil.", func(ctx convey.C) {
  338. ctx.So(err, convey.ShouldBeNil)
  339. ctx.So(minID, convey.ShouldNotBeNil)
  340. })
  341. })
  342. })
  343. }
  344. func TestDaoDailyBillListByVer(t *testing.T) {
  345. convey.Convey("DailyBillListByVer", t, func(ctx convey.C) {
  346. var (
  347. c = context.Background()
  348. ver = int64(20181030)
  349. fromID = int64(0)
  350. limit = int(10)
  351. )
  352. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  353. maxID, data, err := d.DailyBillListByVer(c, ver, fromID, limit)
  354. ctx.Convey("Then err should be nil.maxID,data should not be nil.", func(ctx convey.C) {
  355. ctx.So(err, convey.ShouldBeNil)
  356. ctx.So(data, convey.ShouldNotBeNil)
  357. ctx.So(maxID, convey.ShouldNotBeNil)
  358. })
  359. })
  360. })
  361. }
  362. func TestDaoMinIDDailyBillByMonthVer(t *testing.T) {
  363. convey.Convey("MinIDDailyBillByMonthVer", t, func(ctx convey.C) {
  364. var (
  365. c = context.Background()
  366. monthVer = int64(201811)
  367. )
  368. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  369. minID, err := d.MinIDDailyBillByMonthVer(c, monthVer)
  370. ctx.Convey("Then err should be nil.minID should not be nil.", func(ctx convey.C) {
  371. ctx.So(err, convey.ShouldBeNil)
  372. ctx.So(minID, convey.ShouldNotBeNil)
  373. })
  374. })
  375. })
  376. }
  377. func TestDaoDailyBillListByMonthVer(t *testing.T) {
  378. convey.Convey("DailyBillListByMonthVer", t, func(ctx convey.C) {
  379. var (
  380. c = context.Background()
  381. monthVer = int64(201811)
  382. fromID = int64(0)
  383. limit = int(10)
  384. )
  385. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  386. maxID, data, err := d.DailyBillListByMonthVer(c, monthVer, fromID, limit)
  387. ctx.Convey("Then err should be nil.maxID,data should not be nil.", func(ctx convey.C) {
  388. ctx.So(err, convey.ShouldBeNil)
  389. ctx.So(data, convey.ShouldNotBeNil)
  390. ctx.So(maxID, convey.ShouldNotBeNil)
  391. })
  392. })
  393. })
  394. }
  395. func TestDaoTXInsertLogDailyBill(t *testing.T) {
  396. convey.Convey("TXInsertLogDailyBill", t, func(ctx convey.C) {
  397. var (
  398. c = context.Background()
  399. tx, _ = d.BeginTran(c)
  400. log = &model.LogBillDaily{
  401. OrderID: fmt.Sprintf("ut_%d", time.Now().Unix()),
  402. }
  403. )
  404. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  405. id, err := d.TXInsertLogDailyBill(c, tx, log)
  406. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  407. ctx.So(err, convey.ShouldBeNil)
  408. ctx.So(id, convey.ShouldNotBeNil)
  409. })
  410. })
  411. ctx.Reset(func() {
  412. tx.Commit()
  413. })
  414. })
  415. }
  416. func TestDaoTXInsertLogMonthlyBill(t *testing.T) {
  417. convey.Convey("TXInsertLogMonthlyBill", t, func(ctx convey.C) {
  418. var (
  419. c = context.Background()
  420. tx, _ = d.BeginTran(c)
  421. log = &model.LogBillMonthly{
  422. BillID: fmt.Sprintf("ut_%d", time.Now().Unix()),
  423. BillUserDailyID: fmt.Sprintf("ut_%d", time.Now().Unix()),
  424. }
  425. )
  426. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  427. id, err := d.TXInsertLogMonthlyBill(c, tx, log)
  428. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  429. ctx.So(err, convey.ShouldBeNil)
  430. ctx.So(id, convey.ShouldNotBeNil)
  431. })
  432. })
  433. ctx.Reset(func() {
  434. tx.Commit()
  435. })
  436. })
  437. }
  438. func TestDaoMinIDMonthlyBill(t *testing.T) {
  439. convey.Convey("MinIDMonthlyBill", t, func(ctx convey.C) {
  440. var (
  441. c = context.Background()
  442. ver = int64(201811)
  443. )
  444. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  445. minID, err := d.MinIDMonthlyBill(c, ver)
  446. ctx.Convey("Then err should be nil.minID should not be nil.", func(ctx convey.C) {
  447. ctx.So(err, convey.ShouldBeNil)
  448. ctx.So(minID, convey.ShouldNotBeNil)
  449. })
  450. })
  451. })
  452. }
  453. func TestDaoMonthlyBillList(t *testing.T) {
  454. convey.Convey("MonthlyBillList", t, func(ctx convey.C) {
  455. var (
  456. c = context.Background()
  457. ver = int64(201811)
  458. fromID = int64(0)
  459. limit = int(10)
  460. )
  461. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  462. maxID, data, err := d.MonthlyBillList(c, ver, fromID, limit)
  463. ctx.Convey("Then err should be nil.maxID,data should not be nil.", func(ctx convey.C) {
  464. ctx.So(err, convey.ShouldBeNil)
  465. ctx.So(data, convey.ShouldNotBeNil)
  466. ctx.So(maxID, convey.ShouldNotBeNil)
  467. })
  468. })
  469. })
  470. }
  471. func TestDaoDailyBill(t *testing.T) {
  472. convey.Convey("DailyBill", t, func(ctx convey.C) {
  473. var (
  474. c = context.Background()
  475. mid = int64(46333)
  476. biz = "asset"
  477. currency = "bp"
  478. ver = int64(20181030)
  479. )
  480. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  481. data, err := d.DailyBill(c, mid, biz, currency, ver)
  482. ctx.Convey("Then err should be nil.data should not be nil.", func(ctx convey.C) {
  483. ctx.So(err, convey.ShouldBeNil)
  484. ctx.So(data, convey.ShouldNotBeNil)
  485. })
  486. })
  487. })
  488. }
  489. func TestDaoInsertDailyBill(t *testing.T) {
  490. convey.Convey("InsertDailyBill", t, func(ctx convey.C) {
  491. var (
  492. c = context.Background()
  493. bill = &model.DailyBill{
  494. MonthVer: 201811,
  495. }
  496. )
  497. bill.BillID = fmt.Sprintf("ut_%d", time.Now().Unix())
  498. bill.MID = 46333
  499. bill.Biz = fmt.Sprintf("ut_%d", time.Now().Unix())
  500. bill.Currency = "bp"
  501. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  502. id, err := d.InsertDailyBill(c, bill)
  503. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  504. ctx.So(err, convey.ShouldBeNil)
  505. ctx.So(id, convey.ShouldNotBeNil)
  506. })
  507. })
  508. })
  509. }
  510. func TestDaoTXUpdateDailyBill(t *testing.T) {
  511. convey.Convey("TXUpdateDailyBill", t, func(ctx convey.C) {
  512. var (
  513. c = context.Background()
  514. tx, _ = d.BeginTran(c)
  515. bill = &model.DailyBill{}
  516. )
  517. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  518. rows, err := d.TXUpdateDailyBill(c, tx, bill)
  519. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  520. ctx.So(err, convey.ShouldBeNil)
  521. ctx.So(rows, convey.ShouldNotBeNil)
  522. })
  523. })
  524. ctx.Reset(func() {
  525. tx.Commit()
  526. })
  527. })
  528. }
  529. func TestDaoTXUpsertDeltaDailyBill(t *testing.T) {
  530. convey.Convey("TXUpsertDeltaDailyBill", t, func(ctx convey.C) {
  531. var (
  532. c = context.Background()
  533. tx, _ = d.BeginTran(c)
  534. bill = &model.DailyBill{}
  535. deltaIn = int64(0)
  536. deltaOut = int64(0)
  537. )
  538. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  539. rows, err := d.TXUpsertDeltaDailyBill(c, tx, bill, deltaIn, deltaOut)
  540. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  541. ctx.So(err, convey.ShouldBeNil)
  542. ctx.So(rows, convey.ShouldNotBeNil)
  543. })
  544. })
  545. ctx.Reset(func() {
  546. tx.Commit()
  547. })
  548. })
  549. }
  550. func TestDaoTXUpdateDeltaDailyBill(t *testing.T) {
  551. convey.Convey("TXUpdateDeltaDailyBill", t, func(ctx convey.C) {
  552. var (
  553. c = context.Background()
  554. tx, _ = d.BeginTran(c)
  555. deltaIn = int64(0)
  556. deltaOut = int64(0)
  557. mid = int64(0)
  558. biz = "archive"
  559. currency = "bp"
  560. ver = int64(20181030)
  561. )
  562. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  563. rows, err := d.TXUpdateDeltaDailyBill(c, tx, deltaIn, deltaOut, mid, biz, currency, ver)
  564. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  565. ctx.So(err, convey.ShouldBeNil)
  566. ctx.So(rows, convey.ShouldNotBeNil)
  567. })
  568. })
  569. ctx.Reset(func() {
  570. tx.Commit()
  571. })
  572. })
  573. }
  574. func TestDaoMonthlyBill(t *testing.T) {
  575. convey.Convey("MonthlyBill", t, func(ctx convey.C) {
  576. var (
  577. c = context.Background()
  578. mid = int64(46333)
  579. biz = "asset"
  580. currency = "bp"
  581. ver = int64(201811)
  582. )
  583. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  584. data, err := d.MonthlyBill(c, mid, biz, currency, ver)
  585. ctx.Convey("Then err should be nil.data should not be nil.", func(ctx convey.C) {
  586. ctx.So(err, convey.ShouldBeNil)
  587. ctx.So(data, convey.ShouldNotBeNil)
  588. })
  589. })
  590. })
  591. }
  592. func TestDaoInsertMonthlyBill(t *testing.T) {
  593. convey.Convey("InsertMonthlyBill", t, func(ctx convey.C) {
  594. var (
  595. c = context.Background()
  596. bill = &model.Bill{
  597. BillID: fmt.Sprintf("ut_%d", time.Now().Unix()),
  598. MID: 46333,
  599. Biz: fmt.Sprintf("ut_%d", time.Now().Unix()),
  600. Currency: "bp",
  601. }
  602. )
  603. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  604. id, err := d.InsertMonthlyBill(c, bill)
  605. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  606. ctx.So(err, convey.ShouldBeNil)
  607. ctx.So(id, convey.ShouldNotBeNil)
  608. })
  609. })
  610. })
  611. }
  612. func TestDaoTXUpdateMonthlyBill(t *testing.T) {
  613. convey.Convey("TXUpdateMonthlyBill", t, func(ctx convey.C) {
  614. var (
  615. c = context.Background()
  616. tx, _ = d.BeginTran(c)
  617. bill = &model.Bill{}
  618. )
  619. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  620. rows, err := d.TXUpdateMonthlyBill(c, tx, bill)
  621. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  622. ctx.So(err, convey.ShouldBeNil)
  623. ctx.So(rows, convey.ShouldNotBeNil)
  624. })
  625. })
  626. ctx.Reset(func() {
  627. tx.Commit()
  628. })
  629. })
  630. }
  631. func TestDaoTXUpsertDeltaMonthlyBill(t *testing.T) {
  632. convey.Convey("TXUpsertDeltaMonthlyBill", t, func(ctx convey.C) {
  633. var (
  634. c = context.Background()
  635. tx, _ = d.BeginTran(c)
  636. bill = &model.Bill{}
  637. deltaIn = int64(0)
  638. deltaOut = int64(0)
  639. )
  640. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  641. rows, err := d.TXUpsertDeltaMonthlyBill(c, tx, bill, deltaIn, deltaOut)
  642. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  643. ctx.So(err, convey.ShouldBeNil)
  644. ctx.So(rows, convey.ShouldNotBeNil)
  645. })
  646. })
  647. ctx.Reset(func() {
  648. tx.Commit()
  649. })
  650. })
  651. }
  652. func TestDaoTXUpdateDeltaMonthlyBill(t *testing.T) {
  653. convey.Convey("TXUpdateDeltaMonthlyBill", t, func(ctx convey.C) {
  654. var (
  655. c = context.Background()
  656. tx, _ = d.BeginTran(c)
  657. deltaIn = int64(0)
  658. deltaOut = int64(0)
  659. mid = int64(46333)
  660. biz = "asset"
  661. currency = "bp"
  662. ver = int64(201811)
  663. )
  664. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  665. rows, err := d.TXUpdateDeltaMonthlyBill(c, tx, deltaIn, deltaOut, mid, biz, currency, ver)
  666. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  667. ctx.So(err, convey.ShouldBeNil)
  668. ctx.So(rows, convey.ShouldNotBeNil)
  669. })
  670. })
  671. ctx.Reset(func() {
  672. tx.Commit()
  673. })
  674. })
  675. }
  676. func TestDaoMinIDUserAccount(t *testing.T) {
  677. convey.Convey("MinIDUserAccount", t, func(ctx convey.C) {
  678. var (
  679. c = context.Background()
  680. beginTime = time.Now()
  681. )
  682. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  683. minID, err := d.MinIDUserAccount(c, beginTime)
  684. ctx.Convey("Then err should be nil.minID should not be nil.", func(ctx convey.C) {
  685. ctx.So(err, convey.ShouldBeNil)
  686. ctx.So(minID, convey.ShouldNotBeNil)
  687. })
  688. })
  689. })
  690. }
  691. func TestDaoUserAccountList(t *testing.T) {
  692. convey.Convey("UserAccountList", t, func(ctx convey.C) {
  693. var (
  694. c = context.Background()
  695. beginTime = time.Now()
  696. endTime = time.Now()
  697. fromID = int64(0)
  698. limit = int(10)
  699. )
  700. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  701. maxID, _, err := d.UserAccountList(c, beginTime, endTime, fromID, limit)
  702. ctx.Convey("Then err should be nil.maxID,datas should not be nil.", func(ctx convey.C) {
  703. ctx.So(err, convey.ShouldBeNil)
  704. // ctx.So(datas, convey.ShouldNotBeNil)
  705. ctx.So(maxID, convey.ShouldNotBeNil)
  706. })
  707. })
  708. })
  709. }
  710. func TestDaoInsertUserAccount(t *testing.T) {
  711. convey.Convey("InsertUserAccount", t, func(ctx convey.C) {
  712. var (
  713. c = context.Background()
  714. account = &model.UserAccount{
  715. MID: 46333,
  716. }
  717. )
  718. account.Biz = fmt.Sprintf("ut_%d", time.Now().Unix())
  719. account.Currency = "bp"
  720. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  721. id, err := d.InsertUserAccount(c, account)
  722. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  723. ctx.So(err, convey.ShouldBeNil)
  724. ctx.So(id, convey.ShouldNotBeNil)
  725. })
  726. })
  727. })
  728. }
  729. func TestDaoUserAccount(t *testing.T) {
  730. convey.Convey("UserAccount", t, func(ctx convey.C) {
  731. var (
  732. c = context.Background()
  733. mid = int64(46333)
  734. biz = "asset"
  735. currency = "bp"
  736. )
  737. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  738. data, err := d.UserAccount(c, mid, biz, currency)
  739. ctx.Convey("Then err should be nil.data should not be nil.", func(ctx convey.C) {
  740. ctx.So(err, convey.ShouldBeNil)
  741. ctx.So(data, convey.ShouldNotBeNil)
  742. })
  743. })
  744. })
  745. }
  746. func TestDaoTXUpdateUserAccount(t *testing.T) {
  747. convey.Convey("TXUpdateUserAccount", t, func(ctx convey.C) {
  748. var (
  749. c = context.Background()
  750. tx, _ = d.BeginTran(c)
  751. account = &model.UserAccount{}
  752. )
  753. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  754. rows, err := d.TXUpdateUserAccount(c, tx, account)
  755. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  756. ctx.So(err, convey.ShouldBeNil)
  757. ctx.So(rows, convey.ShouldNotBeNil)
  758. })
  759. })
  760. ctx.Reset(func() {
  761. tx.Commit()
  762. })
  763. })
  764. }
  765. func TestDaoTXUpsertDeltaUserAccount(t *testing.T) {
  766. convey.Convey("TXUpsertDeltaUserAccount", t, func(ctx convey.C) {
  767. var (
  768. c = context.Background()
  769. tx, _ = d.BeginTran(c)
  770. account = &model.UserAccount{
  771. MID: 46333,
  772. }
  773. deltaBalance = int64(0)
  774. )
  775. account.Currency = "bp"
  776. account.Biz = "asset"
  777. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  778. rows, err := d.TXUpsertDeltaUserAccount(c, tx, account, deltaBalance)
  779. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  780. ctx.So(err, convey.ShouldBeNil)
  781. ctx.So(rows, convey.ShouldNotBeNil)
  782. })
  783. })
  784. ctx.Reset(func() {
  785. tx.Commit()
  786. })
  787. })
  788. }
  789. func TestDaoTXUpdateDeltaUserAccount(t *testing.T) {
  790. convey.Convey("TXUpdateDeltaUserAccount", t, func(ctx convey.C) {
  791. var (
  792. c = context.Background()
  793. tx, _ = d.BeginTran(c)
  794. deltaBalance = int64(0)
  795. mid = int64(46333)
  796. biz = "asset"
  797. currency = "bp"
  798. )
  799. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  800. rows, err := d.TXUpdateDeltaUserAccount(c, tx, deltaBalance, mid, biz, currency)
  801. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  802. ctx.So(err, convey.ShouldBeNil)
  803. ctx.So(rows, convey.ShouldNotBeNil)
  804. })
  805. })
  806. ctx.Reset(func() {
  807. tx.Commit()
  808. })
  809. })
  810. }
  811. func TestDaoTXInsertUserAccountLog(t *testing.T) {
  812. convey.Convey("TXInsertUserAccountLog", t, func(ctx convey.C) {
  813. var (
  814. c = context.Background()
  815. tx, _ = d.BeginTran(c)
  816. accountLog = &model.AccountLog{
  817. Name: fmt.Sprintf("ut_%d", time.Now().Unix()),
  818. }
  819. )
  820. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  821. err := d.TXInsertUserAccountLog(c, tx, accountLog)
  822. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  823. ctx.So(err, convey.ShouldBeNil)
  824. })
  825. })
  826. ctx.Reset(func() {
  827. tx.Commit()
  828. })
  829. })
  830. }
  831. func TestDaoBizAccount(t *testing.T) {
  832. convey.Convey("BizAccount", t, func(ctx convey.C) {
  833. var (
  834. c = context.Background()
  835. biz = "asset"
  836. currency = "bp"
  837. )
  838. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  839. data, err := d.BizAccount(c, biz, currency)
  840. ctx.Convey("Then err should be nil.data should not be nil.", func(ctx convey.C) {
  841. ctx.So(err, convey.ShouldBeNil)
  842. ctx.So(data, convey.ShouldNotBeNil)
  843. })
  844. })
  845. })
  846. }
  847. func TestDaoInsertBizAccount(t *testing.T) {
  848. convey.Convey("InsertBizAccount", t, func(ctx convey.C) {
  849. var (
  850. c = context.Background()
  851. account = &model.BizAccount{
  852. Biz: fmt.Sprintf("ut_%d", time.Now().Unix()),
  853. Currency: "bp",
  854. }
  855. )
  856. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  857. id, err := d.InsertBizAccount(c, account)
  858. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  859. ctx.So(err, convey.ShouldBeNil)
  860. ctx.So(id, convey.ShouldNotBeNil)
  861. })
  862. })
  863. })
  864. }
  865. func TestDaoTXUpdateBizAccount(t *testing.T) {
  866. convey.Convey("TXUpdateBizAccount", t, func(ctx convey.C) {
  867. var (
  868. c = context.Background()
  869. tx, _ = d.BeginTran(c)
  870. account = &model.BizAccount{}
  871. )
  872. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  873. rows, err := d.TXUpdateBizAccount(c, tx, account)
  874. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  875. ctx.So(err, convey.ShouldBeNil)
  876. ctx.So(rows, convey.ShouldNotBeNil)
  877. })
  878. })
  879. ctx.Reset(func() {
  880. tx.Commit()
  881. })
  882. })
  883. }
  884. func TestDaoTXUpsertDeltaBizAccount(t *testing.T) {
  885. convey.Convey("TXUpsertDeltaBizAccount", t, func(ctx convey.C) {
  886. var (
  887. c = context.Background()
  888. tx, _ = d.BeginTran(c)
  889. account = &model.BizAccount{
  890. Biz: "asset",
  891. Currency: "bp",
  892. }
  893. deltaBalance = int64(0)
  894. )
  895. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  896. rows, err := d.TXUpsertDeltaBizAccount(c, tx, account, deltaBalance)
  897. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  898. ctx.So(err, convey.ShouldBeNil)
  899. ctx.So(rows, convey.ShouldNotBeNil)
  900. })
  901. })
  902. ctx.Reset(func() {
  903. tx.Commit()
  904. })
  905. })
  906. }
  907. func TestDaoTXUpdateDeltaBizAccount(t *testing.T) {
  908. convey.Convey("TXUpdateDeltaBizAccount", t, func(ctx convey.C) {
  909. var (
  910. c = context.Background()
  911. tx, _ = d.BeginTran(c)
  912. deltaBalance = int64(0)
  913. biz = "asset"
  914. currency = "bp"
  915. )
  916. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  917. rows, err := d.TXUpdateDeltaBizAccount(c, tx, deltaBalance, biz, currency)
  918. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  919. ctx.So(err, convey.ShouldBeNil)
  920. ctx.So(rows, convey.ShouldNotBeNil)
  921. })
  922. })
  923. ctx.Reset(func() {
  924. tx.Commit()
  925. })
  926. })
  927. }
  928. func TestDaoTXInsertBizAccountLog(t *testing.T) {
  929. convey.Convey("TXInsertBizAccountLog", t, func(ctx convey.C) {
  930. var (
  931. c = context.Background()
  932. tx, _ = d.BeginTran(c)
  933. accountLog = &model.AccountLog{
  934. Name: fmt.Sprintf("ut_%d", time.Now().Unix()),
  935. }
  936. )
  937. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  938. err := d.TXInsertBizAccountLog(c, tx, accountLog)
  939. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  940. ctx.So(err, convey.ShouldBeNil)
  941. })
  942. })
  943. ctx.Reset(func() {
  944. tx.Commit()
  945. })
  946. })
  947. }
  948. func TestDaoAggrIncomeUser(t *testing.T) {
  949. convey.Convey("AggrIncomeUser", t, func(ctx convey.C) {
  950. var (
  951. c = context.Background()
  952. mid = int64(46333)
  953. currency = "bp"
  954. )
  955. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  956. data, err := d.AggrIncomeUser(c, mid, currency)
  957. ctx.Convey("Then err should be nil.data should not be nil.", func(ctx convey.C) {
  958. ctx.So(err, convey.ShouldBeNil)
  959. ctx.So(data, convey.ShouldNotBeNil)
  960. })
  961. })
  962. })
  963. }
  964. func TestDaoInsertAggrIncomeUser(t *testing.T) {
  965. convey.Convey("InsertAggrIncomeUser", t, func(ctx convey.C) {
  966. var (
  967. c = context.Background()
  968. aggr = &model.AggrIncomeUser{
  969. MID: int64(2333*1000) + rand.Int63n(1000),
  970. }
  971. )
  972. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  973. id, err := d.InsertAggrIncomeUser(c, aggr)
  974. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  975. ctx.So(err, convey.ShouldBeNil)
  976. ctx.So(id, convey.ShouldNotBeNil)
  977. })
  978. })
  979. })
  980. }
  981. func TestDaoTXUpdateAggrIncomeUser(t *testing.T) {
  982. convey.Convey("TXUpdateAggrIncomeUser", t, func(ctx convey.C) {
  983. var (
  984. c = context.Background()
  985. tx, _ = d.BeginTran(c)
  986. aggr = &model.AggrIncomeUser{}
  987. )
  988. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  989. rows, err := d.TXUpdateAggrIncomeUser(c, tx, aggr)
  990. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  991. ctx.So(err, convey.ShouldBeNil)
  992. ctx.So(rows, convey.ShouldNotBeNil)
  993. })
  994. })
  995. ctx.Reset(func() {
  996. tx.Commit()
  997. })
  998. })
  999. }
  1000. func TestDaoTXUpsertDeltaAggrIncomeUser(t *testing.T) {
  1001. convey.Convey("TXUpsertDeltaAggrIncomeUser", t, func(ctx convey.C) {
  1002. var (
  1003. c = context.Background()
  1004. tx, _ = d.BeginTran(c)
  1005. aggr = &model.AggrIncomeUser{
  1006. MID: 46333,
  1007. Currency: "bp",
  1008. }
  1009. deltaPaySuccess = int64(0)
  1010. deltaPayError = int64(0)
  1011. deltaTotalIn = int64(0)
  1012. deltaTotalOut = int64(0)
  1013. )
  1014. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  1015. rows, err := d.TXUpsertDeltaAggrIncomeUser(c, tx, aggr, deltaPaySuccess, deltaPayError, deltaTotalIn, deltaTotalOut)
  1016. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  1017. ctx.So(err, convey.ShouldBeNil)
  1018. ctx.So(rows, convey.ShouldNotBeNil)
  1019. })
  1020. })
  1021. ctx.Reset(func() {
  1022. tx.Commit()
  1023. })
  1024. })
  1025. }
  1026. func TestDaoTXUpdateDeltaAggrIncomeUser(t *testing.T) {
  1027. convey.Convey("TXUpdateDeltaAggrIncomeUser", t, func(ctx convey.C) {
  1028. var (
  1029. c = context.Background()
  1030. tx, _ = d.BeginTran(c)
  1031. deltaPaySuccess = int64(0)
  1032. deltaPayError = int64(0)
  1033. deltaTotalIn = int64(0)
  1034. deltaTotalOut = int64(0)
  1035. mid = int64(46333)
  1036. currency = "bp"
  1037. )
  1038. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  1039. rows, err := d.TXUpdateDeltaAggrIncomeUser(c, tx, deltaPaySuccess, deltaPayError, deltaTotalIn, deltaTotalOut, mid, currency)
  1040. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  1041. ctx.So(err, convey.ShouldBeNil)
  1042. ctx.So(rows, convey.ShouldNotBeNil)
  1043. })
  1044. })
  1045. ctx.Reset(func() {
  1046. tx.Commit()
  1047. })
  1048. })
  1049. }
  1050. func TestDaoAggrIncomeUserAsset(t *testing.T) {
  1051. convey.Convey("AggrIncomeUserAsset", t, func(ctx convey.C) {
  1052. var (
  1053. c = context.Background()
  1054. mid = int64(46333)
  1055. currency = "bp"
  1056. ver = int64(201810)
  1057. oid = int64(10110846)
  1058. otype = "archive"
  1059. )
  1060. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  1061. data, err := d.AggrIncomeUserAsset(c, mid, currency, ver, oid, otype)
  1062. ctx.Convey("Then err should be nil.data should not be nil.", func(ctx convey.C) {
  1063. ctx.So(err, convey.ShouldBeNil)
  1064. ctx.So(data, convey.ShouldNotBeNil)
  1065. })
  1066. })
  1067. })
  1068. }
  1069. func TestDaoInsertAggrIncomeUserAsset(t *testing.T) {
  1070. convey.Convey("InsertAggrIncomeUserAsset", t, func(ctx convey.C) {
  1071. var (
  1072. c = context.Background()
  1073. aggr = &model.AggrIncomeUserAsset{
  1074. MID: 46333,
  1075. OID: 10110846,
  1076. OType: fmt.Sprintf("ut_%d", time.Now().Unix()),
  1077. Ver: 201810,
  1078. Currency: "bp",
  1079. }
  1080. )
  1081. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  1082. id, err := d.InsertAggrIncomeUserAsset(c, aggr)
  1083. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  1084. ctx.So(err, convey.ShouldBeNil)
  1085. ctx.So(id, convey.ShouldNotBeNil)
  1086. })
  1087. })
  1088. })
  1089. }
  1090. func TestDaoTXUpdateAggrIncomeUserAsset(t *testing.T) {
  1091. convey.Convey("TXUpdateAggrIncomeUserAsset", t, func(ctx convey.C) {
  1092. var (
  1093. c = context.Background()
  1094. tx, _ = d.BeginTran(c)
  1095. aggr = &model.AggrIncomeUserAsset{}
  1096. )
  1097. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  1098. rows, err := d.TXUpdateAggrIncomeUserAsset(c, tx, aggr)
  1099. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  1100. ctx.So(err, convey.ShouldBeNil)
  1101. ctx.So(rows, convey.ShouldNotBeNil)
  1102. })
  1103. })
  1104. ctx.Reset(func() {
  1105. tx.Commit()
  1106. })
  1107. })
  1108. }
  1109. func TestDaoTXUpsertDeltaAggrIncomeUserAsset(t *testing.T) {
  1110. convey.Convey("TXUpsertDeltaAggrIncomeUserAsset", t, func(ctx convey.C) {
  1111. var (
  1112. c = context.Background()
  1113. tx, _ = d.BeginTran(c)
  1114. aggr = &model.AggrIncomeUserAsset{
  1115. MID: 46333,
  1116. OID: 10110846,
  1117. OType: "archive",
  1118. Ver: 201810,
  1119. Currency: "bp",
  1120. }
  1121. deltaPaySuccess = int64(0)
  1122. deltaPayError = int64(0)
  1123. deltaTotalIn = int64(0)
  1124. deltaTotalOut = int64(0)
  1125. )
  1126. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  1127. rows, err := d.TXUpsertDeltaAggrIncomeUserAsset(c, tx, aggr, deltaPaySuccess, deltaPayError, deltaTotalIn, deltaTotalOut)
  1128. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  1129. ctx.So(err, convey.ShouldBeNil)
  1130. ctx.So(rows, convey.ShouldNotBeNil)
  1131. })
  1132. })
  1133. ctx.Reset(func() {
  1134. tx.Commit()
  1135. })
  1136. })
  1137. }
  1138. func TestDaoTXUpdateDeltaAggrIncomeUserAsset(t *testing.T) {
  1139. convey.Convey("TXUpdateDeltaAggrIncomeUserAsset", t, func(ctx convey.C) {
  1140. var (
  1141. c = context.Background()
  1142. tx, _ = d.BeginTran(c)
  1143. deltaPaySuccess = int64(0)
  1144. deltaPayError = int64(0)
  1145. deltaTotalIn = int64(0)
  1146. deltaTotalOut = int64(0)
  1147. mid = int64(46333)
  1148. currency = "bp"
  1149. ver = int64(201810)
  1150. oid = int64(10110846)
  1151. otype = "archive"
  1152. )
  1153. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  1154. rows, err := d.TXUpdateDeltaAggrIncomeUserAsset(c, tx, deltaPaySuccess, deltaPayError, deltaTotalIn, deltaTotalOut, mid, currency, ver, oid, otype)
  1155. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  1156. ctx.So(err, convey.ShouldBeNil)
  1157. ctx.So(rows, convey.ShouldNotBeNil)
  1158. })
  1159. })
  1160. ctx.Reset(func() {
  1161. tx.Commit()
  1162. })
  1163. })
  1164. }
  1165. func TestDaoOrderBadDebt(t *testing.T) {
  1166. convey.Convey("OrderBadDebt", t, func(ctx convey.C) {
  1167. var (
  1168. c = context.Background()
  1169. orderID = "666"
  1170. )
  1171. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  1172. data, err := d.OrderBadDebt(c, orderID)
  1173. ctx.Convey("Then err should be nil.data should not be nil.", func(ctx convey.C) {
  1174. ctx.So(err, convey.ShouldBeNil)
  1175. ctx.So(data, convey.ShouldNotBeNil)
  1176. })
  1177. })
  1178. })
  1179. }
  1180. func TestDaoInsertOrderBadDebt(t *testing.T) {
  1181. convey.Convey("InsertOrderBadDebt", t, func(ctx convey.C) {
  1182. var (
  1183. c = context.Background()
  1184. order = &model.OrderBadDebt{
  1185. OrderID: fmt.Sprintf("ut_%d", time.Now().Unix()),
  1186. Type: "ut",
  1187. }
  1188. )
  1189. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  1190. id, err := d.InsertOrderBadDebt(c, order)
  1191. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  1192. ctx.So(err, convey.ShouldBeNil)
  1193. ctx.So(id, convey.ShouldNotBeNil)
  1194. })
  1195. })
  1196. })
  1197. }
  1198. func TestDaoTXUpdateOrderBadDebt(t *testing.T) {
  1199. convey.Convey("TXUpdateOrderBadDebt", t, func(ctx convey.C) {
  1200. var (
  1201. c = context.Background()
  1202. tx, _ = d.BeginTran(c)
  1203. order = &model.OrderBadDebt{}
  1204. )
  1205. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  1206. rows, err := d.TXUpdateOrderBadDebt(c, tx, order)
  1207. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  1208. ctx.So(err, convey.ShouldBeNil)
  1209. ctx.So(rows, convey.ShouldNotBeNil)
  1210. })
  1211. })
  1212. ctx.Reset(func() {
  1213. tx.Commit()
  1214. })
  1215. })
  1216. }
  1217. func TestDaoTXInsertOrderRechargeShell(t *testing.T) {
  1218. convey.Convey("TXInsertOrderRechargeShell", t, func(ctx convey.C) {
  1219. var (
  1220. c = context.Background()
  1221. tx, _ = d.BeginTran(c)
  1222. order = &model.OrderRechargeShell{
  1223. MID: 46333,
  1224. OrderID: fmt.Sprintf("ut_%d", time.Now().Unix()),
  1225. Biz: fmt.Sprintf("ut_%d", time.Now().Unix()),
  1226. PayMSG: "ut",
  1227. }
  1228. )
  1229. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  1230. id, err := d.TXInsertOrderRechargeShell(c, tx, order)
  1231. ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
  1232. ctx.So(err, convey.ShouldBeNil)
  1233. ctx.So(id, convey.ShouldNotBeNil)
  1234. })
  1235. })
  1236. ctx.Reset(func() {
  1237. tx.Commit()
  1238. })
  1239. })
  1240. }