cheat_test.go 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDaoTxUpdateUpSpyState(t *testing.T) {
  8. convey.Convey("TxUpdateUpSpyState", t, func(ctx convey.C) {
  9. var (
  10. tx, _ = d.BeginTran(context.Background())
  11. state = int(3)
  12. mid = int64(1001)
  13. )
  14. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  15. defer tx.Commit()
  16. d.Exec(context.Background(), "INSERT INTO up_spy_statistics(mid, account_state) VALUES(1001, 4) ON DUPLICATE KEY UPDATE account_state = 4")
  17. rows, err := d.TxUpdateUpSpyState(tx, state, mid)
  18. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  19. ctx.So(err, convey.ShouldBeNil)
  20. ctx.So(rows, convey.ShouldNotBeNil)
  21. })
  22. })
  23. })
  24. }
  25. func TestDaoTxUpdateAvSpyState(t *testing.T) {
  26. convey.Convey("TxUpdateAvSpyState", t, func(ctx convey.C) {
  27. var (
  28. tx, _ = d.BeginTran(context.Background())
  29. state = int(5)
  30. archives = []int64{1000}
  31. )
  32. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  33. defer tx.Commit()
  34. d.Exec(context.Background(), "INSERT INTO archive_spy_statistics(archive_id, deducted) VALUES(1000, 5)")
  35. rows, err := d.TxUpdateAvSpyState(tx, state, archives)
  36. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  37. ctx.So(err, convey.ShouldBeNil)
  38. ctx.So(rows, convey.ShouldNotBeNil)
  39. })
  40. })
  41. })
  42. }
  43. func TestDaoUpSpyCount(t *testing.T) {
  44. convey.Convey("UpSpyCount", t, func(ctx convey.C) {
  45. var (
  46. c = context.Background()
  47. )
  48. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  49. count, err := d.UpSpyCount(c)
  50. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  51. ctx.So(err, convey.ShouldBeNil)
  52. ctx.So(count, convey.ShouldNotBeNil)
  53. })
  54. })
  55. })
  56. }
  57. func TestDaoUpSpies(t *testing.T) {
  58. convey.Convey("UpSpies", t, func(ctx convey.C) {
  59. var (
  60. c = context.Background()
  61. query = "WHERE"
  62. offset = int(0)
  63. limit = int(10)
  64. )
  65. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  66. _, err := d.UpSpies(c, query, offset, limit)
  67. ctx.Convey("Then err should be nil.spies should not be nil.", func(ctx convey.C) {
  68. ctx.So(err, convey.ShouldNotBeNil)
  69. })
  70. })
  71. })
  72. }
  73. func TestDaoArchiveSpyCount(t *testing.T) {
  74. convey.Convey("ArchiveSpyCount", t, func(ctx convey.C) {
  75. var (
  76. c = context.Background()
  77. query = ""
  78. )
  79. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  80. count, err := d.ArchiveSpyCount(c, query)
  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 TestDaoArchiveSpies(t *testing.T) {
  89. convey.Convey("ArchiveSpies", t, func(ctx convey.C) {
  90. var (
  91. c = context.Background()
  92. query = ""
  93. offset = int(0)
  94. limit = int(10)
  95. )
  96. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  97. spies, err := d.ArchiveSpies(c, query, offset, limit)
  98. ctx.Convey("Then err should be nil.spies should not be nil.", func(ctx convey.C) {
  99. ctx.So(err, convey.ShouldBeNil)
  100. ctx.So(spies, convey.ShouldNotBeNil)
  101. })
  102. })
  103. })
  104. }
  105. func TestDaoCheatFansCount(t *testing.T) {
  106. convey.Convey("CheatFansCount", t, func(ctx convey.C) {
  107. var (
  108. c = context.Background()
  109. )
  110. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  111. count, err := d.CheatFansCount(c)
  112. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  113. ctx.So(err, convey.ShouldBeNil)
  114. ctx.So(count, convey.ShouldNotBeNil)
  115. })
  116. })
  117. })
  118. }
  119. func TestDaoCheatFans(t *testing.T) {
  120. convey.Convey("CheatFans", t, func(ctx convey.C) {
  121. var (
  122. c = context.Background()
  123. from = int64(0)
  124. limit = int64(100)
  125. )
  126. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  127. fans, err := d.CheatFans(c, from, limit)
  128. ctx.Convey("Then err should be nil.fans should not be nil.", func(ctx convey.C) {
  129. ctx.So(err, convey.ShouldBeNil)
  130. ctx.So(fans, convey.ShouldNotBeNil)
  131. })
  132. })
  133. })
  134. }
  135. func TestDaoDelCheatUp(t *testing.T) {
  136. convey.Convey("DelCheatUp", t, func(ctx convey.C) {
  137. var (
  138. c = context.Background()
  139. mid = int64(1000)
  140. )
  141. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  142. d.Exec(c, "INSERT INTO cheat_fans_info(mid, is_deleted) values(1000, 0) ON DUPLICATE KEY UPDATE is_deleted = 0")
  143. rows, err := d.DelCheatUp(c, mid)
  144. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  145. ctx.So(err, convey.ShouldBeNil)
  146. ctx.So(rows, convey.ShouldNotBeNil)
  147. })
  148. })
  149. })
  150. }
  151. func TestDaoInsertCheatFansInfo(t *testing.T) {
  152. convey.Convey("InsertCheatFansInfo", t, func(ctx convey.C) {
  153. var (
  154. c = context.Background()
  155. values = "(123, 'tt', '2018-09-01', 100, 100, '2018-09-01')"
  156. )
  157. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  158. rows, err := d.InsertCheatFansInfo(c, values)
  159. ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
  160. ctx.So(err, convey.ShouldBeNil)
  161. ctx.So(rows, convey.ShouldNotBeNil)
  162. })
  163. })
  164. })
  165. }
  166. func TestDaoGetUpRealFansCount(t *testing.T) {
  167. convey.Convey("GetUpRealFansCount", t, func(ctx convey.C) {
  168. var (
  169. c = context.Background()
  170. host = ""
  171. mid = int64(100)
  172. )
  173. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  174. _, err := d.GetUpRealFansCount(c, host, mid)
  175. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  176. ctx.So(err, convey.ShouldNotBeNil)
  177. })
  178. })
  179. })
  180. }
  181. func TestDaoGetUpCheatFansCount(t *testing.T) {
  182. convey.Convey("GetUpCheatFansCount", t, func(ctx convey.C) {
  183. var (
  184. c = context.Background()
  185. host = ""
  186. mid = int64(100)
  187. )
  188. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  189. _, err := d.GetUpCheatFansCount(c, host, mid)
  190. ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
  191. ctx.So(err, convey.ShouldNotBeNil)
  192. })
  193. })
  194. })
  195. }