user_test.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/job/main/passport-user-compare/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoQueryUserBase(t *testing.T) {
  9. convey.Convey("QueryUserBase", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. mid = int64(1)
  13. )
  14. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  15. res, err := d.QueryUserBase(c, mid)
  16. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldBeNil)
  18. ctx.So(res, convey.ShouldNotBeNil)
  19. })
  20. })
  21. })
  22. }
  23. func TestDaoUpdateUserBase(t *testing.T) {
  24. convey.Convey("UpdateUserBase", t, func(ctx convey.C) {
  25. var (
  26. c = context.Background()
  27. a = &model.UserBase{
  28. Mid: 1111111,
  29. UserID: "test_0000_0001",
  30. Pwd: []byte{},
  31. Salt: "",
  32. }
  33. )
  34. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  35. affected, err := d.UpdateUserBase(c, a)
  36. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  37. ctx.So(err, convey.ShouldBeNil)
  38. ctx.So(affected, convey.ShouldNotBeNil)
  39. })
  40. })
  41. })
  42. }
  43. func TestDaoInsertUserBase(t *testing.T) {
  44. convey.Convey("InsertUserBase", t, func(ctx convey.C) {
  45. var (
  46. c = context.Background()
  47. a = &model.UserBase{
  48. Mid: 1111111111,
  49. UserID: "test_0000_0002",
  50. Pwd: []byte{},
  51. Salt: "",
  52. }
  53. )
  54. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  55. affected, err := d.InsertUserBase(c, a)
  56. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  57. ctx.So(err, convey.ShouldNotBeNil)
  58. ctx.So(affected, convey.ShouldNotBeNil)
  59. })
  60. })
  61. })
  62. }
  63. func TestDaoQueryUserTel(t *testing.T) {
  64. convey.Convey("QueryUserTel", t, func(ctx convey.C) {
  65. var (
  66. c = context.Background()
  67. mid = int64(1111111111)
  68. )
  69. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  70. res, err := d.QueryUserTel(c, mid)
  71. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  72. ctx.So(err, convey.ShouldBeNil)
  73. ctx.So(res, convey.ShouldNotBeNil)
  74. })
  75. })
  76. })
  77. }
  78. func TestDaoUpdateUserTel(t *testing.T) {
  79. convey.Convey("UpdateUserTel", t, func(ctx convey.C) {
  80. var (
  81. c = context.Background()
  82. a = &model.UserTel{
  83. Mid: 1111111111,
  84. Tel: []byte{},
  85. Cid: "",
  86. }
  87. )
  88. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  89. affected, err := d.UpdateUserTel(c, a)
  90. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  91. ctx.So(err, convey.ShouldBeNil)
  92. ctx.So(affected, convey.ShouldNotBeNil)
  93. })
  94. })
  95. })
  96. }
  97. func TestDaoInsertUserTel(t *testing.T) {
  98. convey.Convey("InsertUserTel", t, func(ctx convey.C) {
  99. var (
  100. c = context.Background()
  101. a = &model.UserTel{
  102. Mid: 1111111111,
  103. Tel: []byte{},
  104. Cid: "",
  105. }
  106. )
  107. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  108. affected, err := d.InsertUserTel(c, a)
  109. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  110. ctx.So(err, convey.ShouldNotBeNil)
  111. ctx.So(affected, convey.ShouldNotBeNil)
  112. })
  113. })
  114. })
  115. }
  116. func TestDaoQueryUserMail(t *testing.T) {
  117. convey.Convey("QueryUserMail", t, func(ctx convey.C) {
  118. var (
  119. c = context.Background()
  120. mid = int64(1111111111)
  121. )
  122. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  123. res, err := d.QueryUserMail(c, mid)
  124. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  125. ctx.So(err, convey.ShouldBeNil)
  126. ctx.So(res, convey.ShouldNotBeNil)
  127. })
  128. })
  129. })
  130. }
  131. func TestDaoUpdateUserMail(t *testing.T) {
  132. convey.Convey("UpdateUserMail", t, func(ctx convey.C) {
  133. var (
  134. c = context.Background()
  135. a = &model.UserEmail{
  136. Mid: 1111111111,
  137. Email: []byte{},
  138. }
  139. )
  140. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  141. affected, err := d.UpdateUserMail(c, a)
  142. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  143. ctx.So(err, convey.ShouldBeNil)
  144. ctx.So(affected, convey.ShouldNotBeNil)
  145. })
  146. })
  147. })
  148. }
  149. func TestDaoUpdateUserMailVerified(t *testing.T) {
  150. convey.Convey("UpdateUserMailVerified", t, func(ctx convey.C) {
  151. var (
  152. c = context.Background()
  153. a = &model.UserEmail{
  154. Mid: 1111111111,
  155. Email: []byte{},
  156. }
  157. )
  158. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  159. affected, err := d.UpdateUserMailVerified(c, a)
  160. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  161. ctx.So(err, convey.ShouldBeNil)
  162. ctx.So(affected, convey.ShouldNotBeNil)
  163. })
  164. })
  165. })
  166. }
  167. func TestDaoInsertUserEmail(t *testing.T) {
  168. convey.Convey("InsertUserEmail", t, func(ctx convey.C) {
  169. var (
  170. c = context.Background()
  171. a = &model.UserEmail{
  172. Mid: 1111111111,
  173. Email: []byte{},
  174. }
  175. )
  176. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  177. affected, err := d.InsertUserEmail(c, a)
  178. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  179. ctx.So(err, convey.ShouldNotBeNil)
  180. ctx.So(affected, convey.ShouldNotBeNil)
  181. })
  182. })
  183. })
  184. }
  185. func TestDaoQueryUserSafeQuestion(t *testing.T) {
  186. convey.Convey("QueryUserSafeQuestion", t, func(ctx convey.C) {
  187. var (
  188. c = context.Background()
  189. mid = int64(1111111111)
  190. )
  191. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  192. res, err := d.QueryUserSafeQuestion(c, mid)
  193. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  194. ctx.So(err, convey.ShouldBeNil)
  195. ctx.So(res, convey.ShouldBeNil)
  196. })
  197. })
  198. })
  199. }
  200. func TestDaoUpdateUserSafeQuestion(t *testing.T) {
  201. convey.Convey("UpdateUserSafeQuestion", t, func(ctx convey.C) {
  202. var (
  203. c = context.Background()
  204. a = &model.UserSafeQuestion{
  205. Mid: 1111111111,
  206. }
  207. )
  208. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  209. affected, err := d.UpdateUserSafeQuestion(c, a)
  210. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  211. ctx.So(err, convey.ShouldBeNil)
  212. ctx.So(affected, convey.ShouldNotBeNil)
  213. })
  214. })
  215. })
  216. }
  217. func TestDaoInsertUserSafeQuestion(t *testing.T) {
  218. convey.Convey("InsertUserSafeQuestion", t, func(ctx convey.C) {
  219. var (
  220. c = context.Background()
  221. a = &model.UserSafeQuestion{
  222. Mid: 1111111111,
  223. }
  224. )
  225. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  226. affected, err := d.InsertUserSafeQuestion(c, a)
  227. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  228. ctx.So(err, convey.ShouldNotBeNil)
  229. ctx.So(affected, convey.ShouldNotBeNil)
  230. })
  231. })
  232. })
  233. }
  234. func TestDaoQueryUserThirdBind(t *testing.T) {
  235. convey.Convey("QueryUserThirdBind", t, func(ctx convey.C) {
  236. var (
  237. c = context.Background()
  238. mid = int64(1111111111)
  239. platform = int64(1)
  240. )
  241. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  242. res, err := d.QueryUserThirdBind(c, mid, platform)
  243. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  244. ctx.So(err, convey.ShouldBeNil)
  245. ctx.So(res, convey.ShouldBeNil)
  246. })
  247. })
  248. })
  249. }
  250. func TestDaoUpdateUserThirdBind(t *testing.T) {
  251. convey.Convey("UpdateUserThirdBind", t, func(ctx convey.C) {
  252. var (
  253. c = context.Background()
  254. a = &model.UserThirdBind{
  255. Mid: 1111111111,
  256. }
  257. )
  258. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  259. affected, err := d.UpdateUserThirdBind(c, a)
  260. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  261. ctx.So(err, convey.ShouldBeNil)
  262. ctx.So(affected, convey.ShouldNotBeNil)
  263. })
  264. })
  265. })
  266. }
  267. func TestDaoInsertUserThirdBind(t *testing.T) {
  268. convey.Convey("InsertUserThirdBind", t, func(ctx convey.C) {
  269. var (
  270. c = context.Background()
  271. a = &model.UserThirdBind{
  272. Mid: 1111111111,
  273. }
  274. )
  275. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  276. affected, err := d.InsertUserThirdBind(c, a)
  277. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  278. ctx.So(err, convey.ShouldBeNil)
  279. ctx.So(affected, convey.ShouldNotBeNil)
  280. })
  281. })
  282. })
  283. }
  284. func TestDaoQueryCountryCode(t *testing.T) {
  285. convey.Convey("QueryCountryCode", t, func(ctx convey.C) {
  286. var (
  287. c = context.Background()
  288. )
  289. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  290. res, err := d.QueryCountryCode(c)
  291. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  292. ctx.So(err, convey.ShouldBeNil)
  293. ctx.So(res, convey.ShouldNotBeNil)
  294. })
  295. })
  296. })
  297. }
  298. func TestDaoGetMidByTel(t *testing.T) {
  299. convey.Convey("GetMidByTel", t, func(ctx convey.C) {
  300. var (
  301. c = context.Background()
  302. a = &model.UserTel{}
  303. )
  304. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  305. mid, err := d.GetMidByTel(c, a)
  306. ctx.Convey("Then err should be nil.mid should not be nil.", func(ctx convey.C) {
  307. ctx.So(err, convey.ShouldNotBeNil)
  308. ctx.So(mid, convey.ShouldNotBeNil)
  309. })
  310. })
  311. })
  312. }
  313. func TestDaoGetMidByEmail(t *testing.T) {
  314. convey.Convey("GetMidByEmail", t, func(ctx convey.C) {
  315. var (
  316. c = context.Background()
  317. a = &model.UserEmail{}
  318. )
  319. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  320. mid, err := d.GetMidByEmail(c, a)
  321. ctx.Convey("Then err should be nil.mid should not be nil.", func(ctx convey.C) {
  322. ctx.So(err, convey.ShouldNotBeNil)
  323. ctx.So(mid, convey.ShouldNotBeNil)
  324. })
  325. })
  326. })
  327. }
  328. func TestDaoGetUnverifiedEmail(t *testing.T) {
  329. convey.Convey("GetUnverifiedEmail", t, func(ctx convey.C) {
  330. var (
  331. c = context.Background()
  332. start = int64(0)
  333. )
  334. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  335. res, err := d.GetUnverifiedEmail(c, start)
  336. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  337. ctx.So(err, convey.ShouldBeNil)
  338. ctx.So(res, convey.ShouldNotBeNil)
  339. })
  340. })
  341. })
  342. }
  343. func TestDaoGetUserRegOriginByMid(t *testing.T) {
  344. convey.Convey("GetUserRegOriginByMid", t, func(ctx convey.C) {
  345. var (
  346. c = context.Background()
  347. mid = int64(0)
  348. )
  349. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  350. res, err := d.GetUserRegOriginByMid(c, mid)
  351. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  352. ctx.So(err, convey.ShouldBeNil)
  353. ctx.So(res, convey.ShouldNotBeNil)
  354. })
  355. })
  356. })
  357. }
  358. func TestDaoInsertUpdateUserRegOriginType(t *testing.T) {
  359. convey.Convey("InsertUpdateUserRegOriginType", t, func(ctx convey.C) {
  360. var (
  361. c = context.Background()
  362. a = &model.UserRegOrigin{}
  363. )
  364. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  365. affected, err := d.InsertUpdateUserRegOriginType(c, a)
  366. ctx.Convey("Then err should be nil.affected should not be nil.", func(ctx convey.C) {
  367. ctx.So(err, convey.ShouldBeNil)
  368. ctx.So(affected, convey.ShouldNotBeNil)
  369. })
  370. })
  371. })
  372. }
  373. func TestDaotableIndex(t *testing.T) {
  374. convey.Convey("tableIndex", t, func(ctx convey.C) {
  375. var (
  376. mid = int64(0)
  377. )
  378. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  379. p1 := tableIndex(mid)
  380. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  381. ctx.So(p1, convey.ShouldNotBeNil)
  382. })
  383. })
  384. })
  385. }