mcn_test.go 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. xtime "go-common/library/time"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoUpMcnSignStateOP(t *testing.T) {
  9. convey.Convey("UpMcnSignStateOP", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. signID = int64(0)
  13. state = int8(0)
  14. )
  15. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  16. rows, err := d.UpMcnSignStateOP(c, signID, state)
  17. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  18. ctx.So(err, convey.ShouldBeNil)
  19. ctx.So(rows, convey.ShouldNotBeNil)
  20. })
  21. })
  22. })
  23. }
  24. func TestDaoUpMcnUpStateOP(t *testing.T) {
  25. convey.Convey("UpMcnUpStateOP", t, func(ctx convey.C) {
  26. var (
  27. c = context.Background()
  28. signUpID = int64(0)
  29. state = int8(0)
  30. )
  31. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  32. rows, err := d.UpMcnUpStateOP(c, signUpID, state)
  33. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  34. ctx.So(err, convey.ShouldBeNil)
  35. ctx.So(rows, convey.ShouldNotBeNil)
  36. })
  37. })
  38. })
  39. }
  40. func TestDaoUpMcnSignPayExpOP(t *testing.T) {
  41. convey.Convey("UpMcnSignPayExpOP", t, func(ctx convey.C) {
  42. var (
  43. c = context.Background()
  44. signPayID = int64(0)
  45. )
  46. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  47. rows, err := d.UpMcnSignPayExpOP(c, signPayID)
  48. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  49. ctx.So(err, convey.ShouldBeNil)
  50. ctx.So(rows, convey.ShouldNotBeNil)
  51. })
  52. })
  53. })
  54. }
  55. func TestDaoAddMcnDataSummary(t *testing.T) {
  56. convey.Convey("AddMcnDataSummary", t, func(ctx convey.C) {
  57. var (
  58. c = context.Background()
  59. mcnMid = int64(0)
  60. signID = int64(1)
  61. upCount = int64(0)
  62. fansCountAccumulate = int64(0)
  63. genDate xtime.Time
  64. )
  65. var _, err = d.db.Exec(c, "delete from mcn_data_summary where sign_id=? and generate_date='1970-01-01'", signID)
  66. if err != nil {
  67. t.Logf("err=%v", err)
  68. }
  69. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  70. err := d.AddMcnDataSummary(c, mcnMid, signID, upCount, fansCountAccumulate, genDate)
  71. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  72. ctx.So(err, convey.ShouldBeNil)
  73. })
  74. })
  75. })
  76. }
  77. func TestDaoMcnSigns(t *testing.T) {
  78. convey.Convey("McnSigns", t, func(ctx convey.C) {
  79. var (
  80. c = context.Background()
  81. )
  82. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  83. mss, err := d.McnSigns(c)
  84. ctx.Convey("Then err should be nil.mss should not be nil.", func(ctx convey.C) {
  85. ctx.So(err, convey.ShouldBeNil)
  86. ctx.So(mss, convey.ShouldNotBeNil)
  87. })
  88. })
  89. })
  90. }
  91. func TestDaoMcnUps(t *testing.T) {
  92. convey.Convey("McnUps", t, func(ctx convey.C) {
  93. var (
  94. c = context.Background()
  95. offset = int64(0)
  96. limit = int64(1)
  97. )
  98. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  99. ups, err := d.McnUps(c, offset, limit)
  100. ctx.Convey("Then err should be nil.ups should not be nil.", func(ctx convey.C) {
  101. ctx.So(err, convey.ShouldBeNil)
  102. ctx.So(len(ups), convey.ShouldBeGreaterThanOrEqualTo,0)
  103. })
  104. })
  105. })
  106. }
  107. func TestDaoMcnSignPays(t *testing.T) {
  108. convey.Convey("McnSignPays", t, func(ctx convey.C) {
  109. var (
  110. c = context.Background()
  111. )
  112. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  113. sps, err := d.McnSignPayWarns(c)
  114. ctx.Convey("Then err should be nil.sps should not be nil.", func(ctx convey.C) {
  115. ctx.So(err, convey.ShouldBeNil)
  116. ctx.So(len(sps), convey.ShouldBeGreaterThanOrEqualTo, 0)
  117. })
  118. })
  119. })
  120. }
  121. func TestDaoMcnSignMids(t *testing.T) {
  122. convey.Convey("McnSignMids", t, func(ctx convey.C) {
  123. var (
  124. c = context.Background()
  125. )
  126. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  127. msid, sids, err := d.McnSignMids(c)
  128. ctx.Convey("Then err should be nil.msid,sids should not be nil.", func(ctx convey.C) {
  129. ctx.So(err, convey.ShouldBeNil)
  130. ctx.So(sids, convey.ShouldNotBeNil)
  131. ctx.So(msid, convey.ShouldNotBeNil)
  132. })
  133. })
  134. })
  135. }
  136. func TestDaoMcnUPCount(t *testing.T) {
  137. convey.Convey("McnUPCount", t, func(ctx convey.C) {
  138. var (
  139. c = context.Background()
  140. signIDs = []int64{0}
  141. )
  142. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  143. mmc, err := d.McnUPCount(c, signIDs)
  144. ctx.Convey("Then err should be nil.mmc should not be nil.", func(ctx convey.C) {
  145. ctx.So(err, convey.ShouldBeNil)
  146. ctx.So(mmc, convey.ShouldNotBeNil)
  147. })
  148. })
  149. })
  150. }
  151. func TestDaoMcnUPMids(t *testing.T) {
  152. convey.Convey("McnUPMids", t, func(ctx convey.C) {
  153. var (
  154. c = context.Background()
  155. signIDs = []int64{0}
  156. )
  157. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  158. mup, err := d.McnUPMids(c, signIDs)
  159. ctx.Convey("Then err should be nil.mup should not be nil.", func(ctx convey.C) {
  160. ctx.So(err, convey.ShouldBeNil)
  161. ctx.So(mup, convey.ShouldNotBeNil)
  162. })
  163. })
  164. })
  165. }
  166. func TestDaoCrmUpMidsSum(t *testing.T) {
  167. convey.Convey("CrmUpMidsSum", t, func(ctx convey.C) {
  168. var (
  169. c = context.Background()
  170. upMids = []int64{0}
  171. )
  172. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  173. count, err := d.CrmUpMidsSum(c, upMids)
  174. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  175. ctx.So(err, convey.ShouldBeNil)
  176. ctx.So(count, convey.ShouldNotBeNil)
  177. })
  178. })
  179. })
  180. }