elec_mysql_test.go 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. package dao
  2. import (
  3. "context"
  4. "math"
  5. "testing"
  6. "go-common/app/job/main/ugcpay/model"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDaoRawOldElecTradeInfo(t *testing.T) {
  10. convey.Convey("RawOldElecTradeInfo", t, func(ctx convey.C) {
  11. var (
  12. c = context.Background()
  13. orderID = "2016081812152789113137"
  14. )
  15. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  16. data, err := d.RawOldElecTradeInfo(c, orderID)
  17. ctx.Convey("Then err should be nil.data should not be nil.", func(ctx convey.C) {
  18. ctx.So(err, convey.ShouldBeNil)
  19. ctx.So(data, convey.ShouldNotBeNil)
  20. })
  21. })
  22. })
  23. }
  24. func TestDaoTXUpsertElecUPRank(t *testing.T) {
  25. convey.Convey("TXUpsertElecUPRank", t, func(ctx convey.C) {
  26. var (
  27. c = context.Background()
  28. tx, _ = d.BeginTranRank(c)
  29. ver = int64(0)
  30. upMID = int64(233)
  31. payMID = int64(322)
  32. deltaPayAmount = int64(0)
  33. hidden bool
  34. )
  35. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  36. err := d.TXUpsertElecUPRank(c, tx, ver, upMID, payMID, deltaPayAmount, hidden)
  37. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  38. ctx.So(err, convey.ShouldBeNil)
  39. })
  40. })
  41. ctx.Reset(func() {
  42. tx.Commit()
  43. })
  44. })
  45. }
  46. func TestDaoTXUpsertElecAVRank(t *testing.T) {
  47. convey.Convey("TXUpsertElecAVRank", t, func(ctx convey.C) {
  48. var (
  49. c = context.Background()
  50. tx, _ = d.BeginTranRank(c)
  51. ver = int64(0)
  52. avID = int64(233)
  53. upMID = int64(233)
  54. payMID = int64(322)
  55. deltaPayAmount = int64(0)
  56. hidden bool
  57. )
  58. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  59. err := d.TXUpsertElecAVRank(c, tx, ver, avID, upMID, payMID, deltaPayAmount, hidden)
  60. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  61. ctx.So(err, convey.ShouldBeNil)
  62. })
  63. })
  64. ctx.Reset(func() {
  65. tx.Commit()
  66. })
  67. })
  68. }
  69. func TestDaoUpsertElecMessage(t *testing.T) {
  70. convey.Convey("UpsertElecMessage", t, func(ctx convey.C) {
  71. var (
  72. c = context.Background()
  73. data = &model.DBElecMessage{
  74. ID: 233333,
  75. AVID: 233,
  76. UPMID: 233,
  77. PayMID: 322,
  78. Message: "ut",
  79. Replied: true,
  80. }
  81. )
  82. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  83. err := d.UpsertElecMessage(c, data)
  84. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  85. ctx.So(err, convey.ShouldBeNil)
  86. })
  87. })
  88. })
  89. }
  90. func TestDaoUpsertElecReply(t *testing.T) {
  91. convey.Convey("UpsertElecReply", t, func(ctx convey.C) {
  92. var (
  93. c = context.Background()
  94. data = &model.DBElecReply{
  95. ID: 233334,
  96. MSGID: 233333,
  97. Reply: "ut_reply",
  98. Hidden: false,
  99. }
  100. )
  101. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  102. err := d.UpsertElecReply(c, data)
  103. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  104. ctx.So(err, convey.ShouldBeNil)
  105. })
  106. })
  107. })
  108. }
  109. func TestDaoOldElecMessageList(t *testing.T) {
  110. convey.Convey("OldElecMessageList", t, func(ctx convey.C) {
  111. var (
  112. c = context.Background()
  113. startID = int64(0)
  114. limit = int(10)
  115. )
  116. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  117. maxID, list, err := d.OldElecMessageList(c, startID, limit)
  118. ctx.Convey("Then err should be nil.maxID,list should not be nil.", func(ctx convey.C) {
  119. ctx.So(err, convey.ShouldBeNil)
  120. ctx.So(list, convey.ShouldNotBeNil)
  121. ctx.So(maxID, convey.ShouldNotBeNil)
  122. })
  123. })
  124. })
  125. }
  126. func TestDaoOldElecOrderList(t *testing.T) {
  127. convey.Convey("OldElecOrderList", t, func(ctx convey.C) {
  128. var (
  129. c = context.Background()
  130. startID = int64(0)
  131. limit = int(10)
  132. )
  133. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  134. maxID, list, err := d.OldElecOrderList(c, startID, limit)
  135. ctx.Convey("Then err should be nil.maxID,list should not be nil.", func(ctx convey.C) {
  136. ctx.So(err, convey.ShouldBeNil)
  137. ctx.So(list, convey.ShouldNotBeNil)
  138. ctx.So(maxID, convey.ShouldNotBeNil)
  139. })
  140. })
  141. })
  142. }
  143. func TestDaoElecAddSetting(t *testing.T) {
  144. convey.Convey("ElecAddSetting", t, func(ctx convey.C) {
  145. var (
  146. c = context.Background()
  147. mid = int64(46333)
  148. orValue = int32(0x01)
  149. )
  150. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  151. err := d.ElecAddSetting(c, math.MaxInt32, mid, orValue)
  152. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  153. ctx.So(err, convey.ShouldBeNil)
  154. })
  155. })
  156. })
  157. }
  158. func TestDaoElecDeleteSetting(t *testing.T) {
  159. convey.Convey("ElecDeleteSetting", t, func(ctx convey.C) {
  160. var (
  161. c = context.Background()
  162. mid = int64(46333)
  163. andValue = int32(0x7ffffffd)
  164. )
  165. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  166. err := d.ElecDeleteSetting(c, math.MaxInt32, mid, andValue)
  167. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  168. ctx.So(err, convey.ShouldBeNil)
  169. })
  170. })
  171. })
  172. }