sign_up_test.go 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. package upcrm
  2. import (
  3. "testing"
  4. "time"
  5. "go-common/app/admin/main/up/model/signmodel"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestUpcrmInsertSignUp(t *testing.T) {
  9. convey.Convey("InsertSignUp", t, func(ctx convey.C) {
  10. var (
  11. db = d.crmdb
  12. up = &signmodel.SignUp{}
  13. )
  14. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  15. affectedRow, err := d.InsertSignUp(db, up)
  16. d.crmdb.Delete(up)
  17. ctx.Convey("Then err should be nil.affectedRow should not be nil.", func(ctx convey.C) {
  18. ctx.So(err, convey.ShouldBeNil)
  19. ctx.So(affectedRow, convey.ShouldNotBeNil)
  20. })
  21. })
  22. })
  23. }
  24. func TestUpcrmInsertPayInfo(t *testing.T) {
  25. convey.Convey("InsertPayInfo", t, func(ctx convey.C) {
  26. var (
  27. db = d.crmdb
  28. info = &signmodel.SignPay{}
  29. )
  30. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  31. affectedRow, err := d.InsertPayInfo(db, info)
  32. d.crmdb.Delete(info)
  33. ctx.Convey("Then err should be nil.affectedRow should not be nil.", func(ctx convey.C) {
  34. ctx.So(err, convey.ShouldBeNil)
  35. ctx.So(affectedRow, convey.ShouldNotBeNil)
  36. })
  37. })
  38. })
  39. }
  40. func TestUpcrmInsertTaskInfo(t *testing.T) {
  41. convey.Convey("InsertTaskInfo", t, func(ctx convey.C) {
  42. var (
  43. db = d.crmdb
  44. info = &signmodel.SignTask{}
  45. )
  46. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  47. affectedRow, err := d.InsertTaskInfo(db, info)
  48. d.crmdb.Delete(info)
  49. ctx.Convey("Then err should be nil.affectedRow should not be nil.", func(ctx convey.C) {
  50. ctx.So(err, convey.ShouldBeNil)
  51. ctx.So(affectedRow, convey.ShouldNotBeNil)
  52. })
  53. })
  54. })
  55. }
  56. func TestUpcrmInsertContractInfo(t *testing.T) {
  57. convey.Convey("InsertContractInfo", t, func(ctx convey.C) {
  58. var (
  59. db = d.crmdb
  60. info = &signmodel.SignContract{}
  61. )
  62. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  63. affectedRow, err := d.InsertContractInfo(db, info)
  64. d.crmdb.Delete(info)
  65. ctx.Convey("Then err should be nil.affectedRow should not be nil.", func(ctx convey.C) {
  66. ctx.So(err, convey.ShouldBeNil)
  67. ctx.So(affectedRow, convey.ShouldNotBeNil)
  68. })
  69. })
  70. })
  71. }
  72. func TestUpcrmDelPayInfo(t *testing.T) {
  73. convey.Convey("DelPayInfo", t, func(ctx convey.C) {
  74. var (
  75. db = d.crmdb
  76. ids = []int64{}
  77. )
  78. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  79. affectedRow, err := d.DelPayInfo(db, ids)
  80. ctx.Convey("Then err should be nil.affectedRow should not be nil.", func(ctx convey.C) {
  81. ctx.So(err, convey.ShouldBeNil)
  82. ctx.So(affectedRow, convey.ShouldNotBeNil)
  83. })
  84. })
  85. })
  86. }
  87. func TestUpcrmDelTaskInfo(t *testing.T) {
  88. convey.Convey("DelTaskInfo", t, func(ctx convey.C) {
  89. var (
  90. db = d.crmdb
  91. ids = []int64{}
  92. )
  93. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  94. affectedRow, err := d.DelTaskInfo(db, ids)
  95. ctx.Convey("Then err should be nil.affectedRow should not be nil.", func(ctx convey.C) {
  96. ctx.So(err, convey.ShouldBeNil)
  97. ctx.So(affectedRow, convey.ShouldNotBeNil)
  98. })
  99. })
  100. })
  101. }
  102. func TestUpcrmDelSignContract(t *testing.T) {
  103. convey.Convey("DelSignContract", t, func(ctx convey.C) {
  104. var (
  105. db = d.crmdb
  106. ids = []int64{}
  107. )
  108. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  109. affectedRow, err := d.DelSignContract(db, ids)
  110. ctx.Convey("Then err should be nil.affectedRow should not be nil.", func(ctx convey.C) {
  111. ctx.So(err, convey.ShouldBeNil)
  112. ctx.So(affectedRow, convey.ShouldNotBeNil)
  113. })
  114. })
  115. })
  116. }
  117. func TestUpcrmSignUpID(t *testing.T) {
  118. convey.Convey("SignUpID", t, func(ctx convey.C) {
  119. var (
  120. sigID = int64(0)
  121. )
  122. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  123. su, msp, mst, msc, err := d.SignUpID(sigID)
  124. ctx.Convey("Then err should be nil.su,msp,mst,msc should not be nil.", func(ctx convey.C) {
  125. ctx.So(err, convey.ShouldBeNil)
  126. ctx.So(msc, convey.ShouldBeNil)
  127. ctx.So(mst, convey.ShouldBeNil)
  128. ctx.So(msp, convey.ShouldBeNil)
  129. ctx.So(su, convey.ShouldBeNil)
  130. })
  131. })
  132. })
  133. }
  134. func TestUpcrmGetSignIDByCondition(t *testing.T) {
  135. convey.Convey("GetSignIDByCondition", t, func(ctx convey.C) {
  136. var (
  137. arg = &signmodel.SignQueryArg{}
  138. )
  139. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  140. signIDs, err := d.GetSignIDByCondition(arg)
  141. ctx.Convey("Then err should be nil.signIDs should not be nil.", func(ctx convey.C) {
  142. ctx.So(err, convey.ShouldBeNil)
  143. ctx.So(signIDs, convey.ShouldBeNil)
  144. })
  145. })
  146. })
  147. }
  148. func TestUpcrmGetSignUpByID(t *testing.T) {
  149. convey.Convey("GetSignUpByID", t, func(ctx convey.C) {
  150. var (
  151. signID = []uint32{}
  152. order = ""
  153. offset = int(0)
  154. limit = int(0)
  155. query = interface{}(0)
  156. args = interface{}(0)
  157. )
  158. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  159. result, err := d.GetSignUpByID(signID, order, offset, limit, query, args)
  160. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  161. ctx.So(err, convey.ShouldBeNil)
  162. ctx.So(result, convey.ShouldNotBeNil)
  163. })
  164. })
  165. })
  166. }
  167. func TestUpcrmGetSignUpCount(t *testing.T) {
  168. convey.Convey("GetSignUpCount", t, func(ctx convey.C) {
  169. var (
  170. query = ""
  171. args = interface{}(0)
  172. )
  173. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  174. count := d.GetSignUpCount(query, args)
  175. ctx.Convey("Then count should not be nil.", func(ctx convey.C) {
  176. ctx.So(count, convey.ShouldNotBeNil)
  177. })
  178. })
  179. })
  180. }
  181. func TestUpcrmGetTask(t *testing.T) {
  182. convey.Convey("GetTask", t, func(ctx convey.C) {
  183. var (
  184. signID = []uint32{}
  185. state = int(0)
  186. )
  187. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  188. result, err := d.GetTask(signID, state)
  189. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  190. ctx.So(err, convey.ShouldBeNil)
  191. ctx.So(result, convey.ShouldNotBeNil)
  192. })
  193. })
  194. })
  195. }
  196. func TestUpcrmGetPay(t *testing.T) {
  197. convey.Convey("GetPay", t, func(ctx convey.C) {
  198. var (
  199. signID = []uint32{}
  200. )
  201. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  202. result, err := d.GetPay(signID)
  203. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  204. ctx.So(err, convey.ShouldBeNil)
  205. ctx.So(result, convey.ShouldNotBeNil)
  206. })
  207. })
  208. })
  209. }
  210. func TestUpcrmGetContract(t *testing.T) {
  211. convey.Convey("GetContract", t, func(ctx convey.C) {
  212. var (
  213. signID = []uint32{}
  214. )
  215. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  216. result, err := d.GetContract(signID)
  217. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  218. ctx.So(err, convey.ShouldBeNil)
  219. ctx.So(result, convey.ShouldNotBeNil)
  220. })
  221. })
  222. })
  223. }
  224. func TestUpcrmPayComplete(t *testing.T) {
  225. convey.Convey("PayComplete", t, func(ctx convey.C) {
  226. var (
  227. ids = []int64{1, 2}
  228. )
  229. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  230. affectedRow, err := d.PayComplete(ids)
  231. ctx.Convey("Then err should be nil.affectedRow should not be nil.", func(ctx convey.C) {
  232. ctx.So(err, convey.ShouldBeNil)
  233. ctx.So(affectedRow, convey.ShouldNotBeNil)
  234. })
  235. })
  236. })
  237. }
  238. func TestUpcrmGetDueSignUp(t *testing.T) {
  239. convey.Convey("GetDueSignUp", t, func(ctx convey.C) {
  240. var (
  241. now = time.Now()
  242. expireAfterDays = int(0)
  243. )
  244. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  245. result, err := d.GetDueSignUp(now, expireAfterDays)
  246. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  247. ctx.So(err, convey.ShouldBeNil)
  248. ctx.So(result, convey.ShouldNotBeNil)
  249. })
  250. })
  251. })
  252. }
  253. func TestUpcrmGetDuePay(t *testing.T) {
  254. convey.Convey("GetDuePay", t, func(ctx convey.C) {
  255. var (
  256. now = time.Now()
  257. expireAfterDays = int(0)
  258. )
  259. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  260. result, err := d.GetDuePay(now, expireAfterDays)
  261. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  262. ctx.So(err, convey.ShouldBeNil)
  263. ctx.So(result, convey.ShouldNotBeNil)
  264. })
  265. })
  266. })
  267. }
  268. func TestUpcrmUpdateEmailState(t *testing.T) {
  269. convey.Convey("UpdateEmailState", t, func(ctx convey.C) {
  270. var (
  271. table = "sign_up"
  272. ids = []int64{}
  273. state = int8(0)
  274. )
  275. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  276. affectedRow, err := d.UpdateEmailState(table, ids, state)
  277. ctx.Convey("Then err should be nil.affectedRow should not be nil.", func(ctx convey.C) {
  278. ctx.So(err, convey.ShouldBeNil)
  279. ctx.So(affectedRow, convey.ShouldEqual, 0)
  280. })
  281. })
  282. })
  283. }
  284. func TestUpcrmCheckUpHasValidContract(t *testing.T) {
  285. convey.Convey("CheckUpHasValidContract", t, func(ctx convey.C) {
  286. var (
  287. mid = int64(0)
  288. date = time.Now()
  289. )
  290. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  291. exist, err := d.CheckUpHasValidContract(mid, date)
  292. ctx.Convey("Then err should be nil.exist should not be nil.", func(ctx convey.C) {
  293. ctx.So(err, convey.ShouldBeNil)
  294. ctx.So(exist, convey.ShouldNotBeNil)
  295. })
  296. })
  297. })
  298. }