mysql_test.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "go-common/app/job/main/vip/model"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. func Test_SelVipList(t *testing.T) {
  10. var (
  11. res []*model.VipUserInfo
  12. err error
  13. id = 0
  14. mID = 10000
  15. ot = time.Now().Format("2006-01-02")
  16. )
  17. Convey("should return true where err != nil and res not empty", t, func() {
  18. res, err = d.SelVipList(context.TODO(), id, mID, ot)
  19. So(err, ShouldBeNil)
  20. So(res, ShouldNotBeEmpty)
  21. })
  22. }
  23. func Test_UpdateVipUserInfo(t *testing.T) {
  24. vuf := new(model.VipUserInfo)
  25. vuf.ID = 1
  26. vuf.Type = 1
  27. vuf.Status = 0
  28. Convey("should return true where err == nil", t, func() {
  29. tx, err := d.StartTx(context.TODO())
  30. So(err, ShouldBeNil)
  31. _, err = d.UpdateVipUserInfo(tx, vuf)
  32. So(err, ShouldBeNil)
  33. })
  34. }
  35. func Test_SelAppInfo(t *testing.T) {
  36. Convey("should return true where err == nil and res not empty", t, func() {
  37. res, err := d.SelAppInfo(context.TODO())
  38. So(err, ShouldBeNil)
  39. So(res, ShouldNotBeEmpty)
  40. })
  41. }
  42. func Test_SelMaxID(t *testing.T) {
  43. Convey("should return true where err == nil ", t, func() {
  44. r, err := d.SelMaxID(context.TODO())
  45. So(r, ShouldBeGreaterThan, 100)
  46. So(err, ShouldBeNil)
  47. })
  48. }
  49. func TestDao_SelOrderMaxID(t *testing.T) {
  50. Convey("sel order max id", t, func() {
  51. _, err := d.SelOrderMaxID(context.TODO())
  52. So(err, ShouldBeNil)
  53. })
  54. }
  55. func TestDao_SelOldBcoinMaxID(t *testing.T) {
  56. Convey("sel old bcoin Max id", t, func() {
  57. _, err := d.SelOldBcoinMaxID(context.TODO())
  58. So(err, ShouldBeNil)
  59. })
  60. }
  61. func TestDao_SelBcoinMaxID(t *testing.T) {
  62. Convey("sel bcoin maxID", t, func() {
  63. _, err := d.SelBcoinMaxID(context.TODO())
  64. So(err, ShouldBeNil)
  65. })
  66. }
  67. func TestDao_SelChangeHistoryMaxID(t *testing.T) {
  68. Convey("sel change hsitory max id", t, func() {
  69. _, err := d.SelChangeHistoryMaxID(context.TODO())
  70. So(err, ShouldBeNil)
  71. })
  72. }
  73. func TestDao_SelOldOrderMaxID(t *testing.T) {
  74. Convey("sel old Order maxID", t, func() {
  75. _, err := d.SelOldOrderMaxID(context.TODO())
  76. So(err, ShouldBeNil)
  77. })
  78. }
  79. func TestDao_VipStatus(t *testing.T) {
  80. Convey("vip status", t, func() {
  81. _, err := d.VipStatus(context.TODO(), 1)
  82. So(err, ShouldBeNil)
  83. })
  84. }
  85. func TestDao_SelOldBcoinSalaryDataMaps(t *testing.T) {
  86. Convey("vip SelOldBcoinSalaryDataMaps", t, func() {
  87. _, err := d.SelOldBcoinSalaryDataMaps(context.TODO(), []int64{7593623})
  88. So(err, ShouldBeNil)
  89. })
  90. }
  91. func TestDao_SelBcoinSalary(t *testing.T) {
  92. arg := &model.QueryBcoinSalary{
  93. StartID: 1,
  94. EndID: 1,
  95. Status: 1,
  96. }
  97. Convey("vip SelBcoinSalary", t, func() {
  98. _, err := d.SelBcoinSalary(context.TODO(), arg)
  99. So(err, ShouldBeNil)
  100. })
  101. }
  102. func TestDao_SelOldBcoinSalary(t *testing.T) {
  103. arg := &model.VipBcoinSalaryMsg{
  104. Mid: 7593623,
  105. Status: 1,
  106. GiveNowStatus: 1,
  107. Payday: "10",
  108. Amount: 1,
  109. Memo: "memo",
  110. }
  111. Convey("vip AddBcoinSalary", t, func() {
  112. err := d.AddBcoinSalary(context.TODO(), arg)
  113. So(err, ShouldBeNil)
  114. })
  115. Convey("vip UpdateBcoinSalary", t, func() {
  116. err := d.UpdateBcoinSalary(context.TODO(), "10", 7593623, 2)
  117. So(err, ShouldBeNil)
  118. })
  119. Convey("del bcoin salary", t, func() {
  120. err := d.DelBcoinSalary(context.TODO(), "10", 7593623)
  121. So(err, ShouldBeNil)
  122. })
  123. Convey("vip SelOldBcoinSalary", t, func() {
  124. _, err := d.SelOldBcoinSalary(context.TODO(), 1, 1)
  125. So(err, ShouldBeNil)
  126. })
  127. }
  128. func TestDao_SelBcoinSalaryData(t *testing.T) {
  129. Convey("SelBcoinSalaryData", t, func() {
  130. _, err := d.SelBcoinSalaryData(context.TODO(), 1, 1)
  131. So(err, ShouldBeNil)
  132. })
  133. }
  134. func TestDao_SelBcoinSalaryDataMaps(t *testing.T) {
  135. Convey("SelBcoinSalaryDataMaps", t, func() {
  136. _, err := d.SelBcoinSalaryDataMaps(context.TODO(), []int64{1})
  137. So(err, ShouldBeNil)
  138. })
  139. }
  140. func TestDao_SelEffectiveVipList(t *testing.T) {
  141. Convey("SelEffectiveVipList", t, func() {
  142. _, err := d.SelEffectiveVipList(context.TODO(), 1, 1)
  143. So(err, ShouldBeNil)
  144. })
  145. }