blocked_test.go 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/interface/main/credit/model"
  5. "testing"
  6. "time"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestDaoAddBlockedInfo(t *testing.T) {
  10. convey.Convey("AddBlockedInfo", t, func(convCtx convey.C) {
  11. var (
  12. c = context.Background()
  13. r = &model.BlockedInfo{}
  14. )
  15. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  16. err := d.AddBlockedInfo(c, r)
  17. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  18. convCtx.So(err, convey.ShouldBeNil)
  19. })
  20. })
  21. })
  22. }
  23. func TestDaoTxAddBlockedInfo(t *testing.T) {
  24. convey.Convey("TxAddBlockedInfo", t, func(convCtx convey.C) {
  25. var (
  26. tx, _ = d.BeginTran(context.Background())
  27. rs = []*model.BlockedInfo{}
  28. r = &model.BlockedInfo{Uname: "test", UID: 1024}
  29. )
  30. rs = append(rs, r)
  31. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  32. err := d.TxAddBlockedInfo(tx, rs)
  33. if err == nil {
  34. if err = tx.Commit(); err != nil {
  35. tx.Rollback()
  36. }
  37. } else {
  38. tx.Rollback()
  39. }
  40. convCtx.Convey("Then err should be nil.", func(convCtx convey.C) {
  41. convCtx.So(err, convey.ShouldBeNil)
  42. })
  43. })
  44. })
  45. }
  46. func TestDaoBlockedCount(t *testing.T) {
  47. convey.Convey("BlockedCount", t, func(convCtx convey.C) {
  48. var (
  49. c = context.Background()
  50. mid = int64(0)
  51. )
  52. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  53. count, err := d.BlockedCount(c, mid)
  54. convCtx.Convey("Then err should be nil.count should not be nil.", func(convCtx convey.C) {
  55. convCtx.So(err, convey.ShouldBeNil)
  56. convCtx.So(count, convey.ShouldNotBeNil)
  57. })
  58. })
  59. })
  60. }
  61. func TestDaoBlockedNumUser(t *testing.T) {
  62. convey.Convey("BlockedNumUser", t, func(convCtx convey.C) {
  63. var (
  64. c = context.Background()
  65. mid = int64(0)
  66. )
  67. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  68. count, err := d.BlockedNumUser(c, mid)
  69. convCtx.Convey("Then err should be nil.count should not be nil.", func(convCtx convey.C) {
  70. convCtx.So(err, convey.ShouldBeNil)
  71. convCtx.So(count, convey.ShouldNotBeNil)
  72. })
  73. })
  74. })
  75. }
  76. func TestDaoBLKHistoryCount(t *testing.T) {
  77. convey.Convey("BLKHistoryCount", t, func(convCtx convey.C) {
  78. var (
  79. c = context.Background()
  80. ArgHis = &model.ArgHistory{}
  81. )
  82. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  83. count, err := d.BLKHistoryCount(c, ArgHis)
  84. convCtx.Convey("Then err should be nil.count should not be nil.", func(convCtx convey.C) {
  85. convCtx.So(err, convey.ShouldBeNil)
  86. convCtx.So(count, convey.ShouldNotBeNil)
  87. })
  88. })
  89. })
  90. }
  91. func TestDaoBlockTotalTime(t *testing.T) {
  92. convey.Convey("BlockTotalTime", t, func(convCtx convey.C) {
  93. var (
  94. c = context.Background()
  95. mid = int64(0)
  96. ts = time.Now()
  97. )
  98. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  99. total, err := d.BlockTotalTime(c, mid, ts)
  100. convCtx.Convey("Then err should be nil.total should not be nil.", func(convCtx convey.C) {
  101. convCtx.So(err, convey.ShouldBeNil)
  102. convCtx.So(total, convey.ShouldNotBeNil)
  103. })
  104. })
  105. })
  106. }
  107. func TestDaoBlockedUserList(t *testing.T) {
  108. convey.Convey("BlockedUserList", t, func(convCtx convey.C) {
  109. var (
  110. c = context.Background()
  111. mid = int64(0)
  112. )
  113. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  114. res, err := d.BlockedUserList(c, mid)
  115. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  116. convCtx.So(err, convey.ShouldBeNil)
  117. convCtx.So(res, convey.ShouldNotBeNil)
  118. })
  119. })
  120. })
  121. }
  122. func TestDaoBlockedList(t *testing.T) {
  123. convey.Convey("BlockedList", t, func(convCtx convey.C) {
  124. var (
  125. c = context.Background()
  126. otype = int8(0)
  127. btype = int8(0)
  128. )
  129. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  130. res, err := d.BlockedList(c, otype, btype)
  131. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  132. convCtx.So(err, convey.ShouldBeNil)
  133. convCtx.So(res, convey.ShouldNotBeNil)
  134. })
  135. })
  136. })
  137. }
  138. func TestDaoBLKHistorys(t *testing.T) {
  139. convey.Convey("BLKHistorys", t, func(convCtx convey.C) {
  140. var (
  141. c = context.Background()
  142. ah = &model.ArgHistory{MID: 0}
  143. )
  144. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  145. res, err := d.BLKHistorys(c, ah)
  146. convCtx.Convey("Then err should be nil.res should be nil.", func(convCtx convey.C) {
  147. convCtx.So(err, convey.ShouldBeNil)
  148. convCtx.So(res, convey.ShouldBeNil)
  149. })
  150. })
  151. })
  152. }
  153. func TestDaoBlockedInfoByID(t *testing.T) {
  154. convey.Convey("BlockedInfoByID", t, func(convCtx convey.C) {
  155. var (
  156. c = context.Background()
  157. id = int64(234)
  158. )
  159. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  160. r, err := d.BlockedInfoByID(c, id)
  161. convCtx.Convey("Then err should be nil.r should not be nil.", func(convCtx convey.C) {
  162. convCtx.So(err, convey.ShouldBeNil)
  163. convCtx.So(r, convey.ShouldNotBeNil)
  164. })
  165. })
  166. })
  167. }
  168. func TestDaoBlockedInfoIDs(t *testing.T) {
  169. convey.Convey("BlockedInfoIDs", t, func(convCtx convey.C) {
  170. var (
  171. c = context.Background()
  172. ids = []int64{1, 234, 27515668}
  173. )
  174. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  175. res, err := d.BlockedInfoIDs(c, ids)
  176. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  177. convCtx.So(err, convey.ShouldBeNil)
  178. convCtx.So(res, convey.ShouldNotBeNil)
  179. })
  180. })
  181. })
  182. }
  183. func TestDaoBlockedInfos(t *testing.T) {
  184. convey.Convey("BlockedInfos", t, func(convCtx convey.C) {
  185. var (
  186. c = context.Background()
  187. ids = []int64{243, 629}
  188. )
  189. convCtx.Convey("When everything goes positive", func(convCtx convey.C) {
  190. res, err := d.BlockedInfos(c, ids)
  191. convCtx.Convey("Then err should be nil.res should not be nil.", func(convCtx convey.C) {
  192. convCtx.So(err, convey.ShouldBeNil)
  193. convCtx.So(res, convey.ShouldNotBeNil)
  194. })
  195. })
  196. })
  197. }