search_test.go 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/interface/main/web/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoSearchAll(t *testing.T) {
  9. convey.Convey("SearchAll", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. mid = int64(0)
  13. arg = &model.SearchAllArg{Pn: 1, Keyword: "test", Rid: 1}
  14. buvid = ""
  15. ua = ""
  16. )
  17. typ := model.WxSearchType
  18. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  19. res, err := d.SearchAll(c, mid, arg, buvid, ua, typ)
  20. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  21. ctx.So(err, convey.ShouldBeNil)
  22. ctx.So(res, convey.ShouldNotBeNil)
  23. })
  24. })
  25. })
  26. }
  27. func TestDaoSearchVideo(t *testing.T) {
  28. convey.Convey("SearchVideo", t, func(ctx convey.C) {
  29. var (
  30. c = context.Background()
  31. mid = int64(0)
  32. arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypeVideo, Keyword: "test"}
  33. buvid = ""
  34. ua = ""
  35. )
  36. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  37. res, err := d.SearchVideo(c, mid, arg, buvid, ua)
  38. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  39. ctx.So(err, convey.ShouldBeNil)
  40. ctx.So(res, convey.ShouldNotBeNil)
  41. })
  42. })
  43. })
  44. }
  45. func TestDaoSearchBangumi(t *testing.T) {
  46. convey.Convey("SearchBangumi", t, func(ctx convey.C) {
  47. var (
  48. c = context.Background()
  49. mid = int64(0)
  50. arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypeBangumi, Keyword: "test"}
  51. buvid = ""
  52. ua = ""
  53. )
  54. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  55. res, err := d.SearchBangumi(c, mid, arg, buvid, ua)
  56. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  57. ctx.So(err, convey.ShouldBeNil)
  58. ctx.So(res, convey.ShouldNotBeNil)
  59. })
  60. })
  61. })
  62. }
  63. func TestDaoSearchPGC(t *testing.T) {
  64. convey.Convey("SearchPGC", t, func(ctx convey.C) {
  65. var (
  66. c = context.Background()
  67. mid = int64(0)
  68. arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypePGC, Keyword: "test"}
  69. buvid = ""
  70. ua = ""
  71. )
  72. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  73. res, err := d.SearchPGC(c, mid, arg, buvid, ua)
  74. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  75. ctx.So(err, convey.ShouldBeNil)
  76. ctx.So(res, convey.ShouldNotBeNil)
  77. })
  78. })
  79. })
  80. }
  81. func TestDaoSearchLive(t *testing.T) {
  82. convey.Convey("SearchLive", t, func(ctx convey.C) {
  83. var (
  84. c = context.Background()
  85. mid = int64(0)
  86. arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypeLive, Keyword: "test"}
  87. buvid = ""
  88. ua = ""
  89. )
  90. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  91. res, err := d.SearchLive(c, mid, arg, buvid, ua)
  92. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  93. ctx.So(err, convey.ShouldBeNil)
  94. ctx.So(res, convey.ShouldNotBeNil)
  95. })
  96. })
  97. })
  98. }
  99. func TestDaoSearchLiveRoom(t *testing.T) {
  100. convey.Convey("SearchLiveRoom", t, func(ctx convey.C) {
  101. var (
  102. c = context.Background()
  103. mid = int64(0)
  104. arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypeLiveRoom, Keyword: "test"}
  105. buvid = ""
  106. ua = ""
  107. )
  108. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  109. res, err := d.SearchLiveRoom(c, mid, arg, buvid, ua)
  110. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  111. ctx.So(err, convey.ShouldBeNil)
  112. ctx.So(res, convey.ShouldNotBeNil)
  113. })
  114. })
  115. })
  116. }
  117. func TestDaoSearchLiveUser(t *testing.T) {
  118. convey.Convey("SearchLiveUser", t, func(ctx convey.C) {
  119. var (
  120. c = context.Background()
  121. mid = int64(0)
  122. arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypeLiveUser, Keyword: "test"}
  123. buvid = ""
  124. ua = ""
  125. )
  126. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  127. res, err := d.SearchLiveUser(c, mid, arg, buvid, ua)
  128. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  129. ctx.So(err, convey.ShouldBeNil)
  130. ctx.So(res, convey.ShouldNotBeNil)
  131. })
  132. })
  133. })
  134. }
  135. func TestDaoSearchArticle(t *testing.T) {
  136. convey.Convey("SearchArticle", t, func(ctx convey.C) {
  137. var (
  138. c = context.Background()
  139. mid = int64(0)
  140. arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypeArticle, Keyword: "test"}
  141. buvid = ""
  142. ua = ""
  143. )
  144. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  145. res, err := d.SearchArticle(c, mid, arg, buvid, ua)
  146. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  147. ctx.So(err, convey.ShouldBeNil)
  148. ctx.So(res, convey.ShouldNotBeNil)
  149. })
  150. })
  151. })
  152. }
  153. func TestDaoSearchSpecial(t *testing.T) {
  154. convey.Convey("SearchSpecial", t, func(ctx convey.C) {
  155. var (
  156. c = context.Background()
  157. mid = int64(0)
  158. arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypeSpecial, Keyword: "test"}
  159. buvid = ""
  160. ua = ""
  161. )
  162. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  163. res, err := d.SearchSpecial(c, mid, arg, buvid, ua)
  164. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  165. ctx.So(err, convey.ShouldBeNil)
  166. ctx.So(res, convey.ShouldNotBeNil)
  167. })
  168. })
  169. })
  170. }
  171. func TestDaoSearchTopic(t *testing.T) {
  172. convey.Convey("SearchTopic", t, func(ctx convey.C) {
  173. var (
  174. c = context.Background()
  175. mid = int64(0)
  176. arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypeTopic, Keyword: "test"}
  177. buvid = ""
  178. ua = ""
  179. )
  180. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  181. res, err := d.SearchTopic(c, mid, arg, buvid, ua)
  182. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  183. ctx.So(err, convey.ShouldBeNil)
  184. ctx.So(res, convey.ShouldNotBeNil)
  185. })
  186. })
  187. })
  188. }
  189. func TestDaoSearchUser(t *testing.T) {
  190. convey.Convey("SearchUser", t, func(ctx convey.C) {
  191. var (
  192. c = context.Background()
  193. mid = int64(0)
  194. arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypeUser, Keyword: "test"}
  195. buvid = ""
  196. ua = ""
  197. )
  198. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  199. res, err := d.SearchUser(c, mid, arg, buvid, ua)
  200. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  201. ctx.So(err, convey.ShouldBeNil)
  202. ctx.So(res, convey.ShouldNotBeNil)
  203. })
  204. })
  205. })
  206. }
  207. func TestDaoSearchPhoto(t *testing.T) {
  208. convey.Convey("SearchPhoto", t, func(ctx convey.C) {
  209. var (
  210. c = context.Background()
  211. mid = int64(0)
  212. arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypePhoto, Keyword: "test"}
  213. buvid = ""
  214. ua = ""
  215. )
  216. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  217. res, err := d.SearchPhoto(c, mid, arg, buvid, ua)
  218. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  219. ctx.So(err, convey.ShouldBeNil)
  220. ctx.So(res, convey.ShouldNotBeNil)
  221. })
  222. })
  223. })
  224. }
  225. func TestDaoSearchRec(t *testing.T) {
  226. convey.Convey("SearchRec", t, func(ctx convey.C) {
  227. var (
  228. c = context.Background()
  229. mid = int64(0)
  230. pn = int(1)
  231. ps = int(10)
  232. keyword = "test"
  233. fromSource = ""
  234. buvid = ""
  235. ua = ""
  236. )
  237. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  238. res, err := d.SearchRec(c, mid, pn, ps, keyword, fromSource, buvid, ua)
  239. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  240. ctx.So(err, convey.ShouldBeNil)
  241. ctx.So(res, convey.ShouldNotBeNil)
  242. })
  243. })
  244. })
  245. }
  246. func TestDaoSearchDefault(t *testing.T) {
  247. convey.Convey("SearchDefault", t, func(ctx convey.C) {
  248. var (
  249. c = context.Background()
  250. mid = int64(0)
  251. fromSource = ""
  252. buvid = ""
  253. ua = ""
  254. )
  255. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  256. data, err := d.SearchDefault(c, mid, fromSource, buvid, ua)
  257. ctx.Convey("Then err should be nil.data should not be nil.", func(ctx convey.C) {
  258. ctx.So(err, convey.ShouldBeNil)
  259. ctx.So(data, convey.ShouldNotBeNil)
  260. })
  261. })
  262. })
  263. }
  264. func TestDaoUpRecommend(t *testing.T) {
  265. convey.Convey("UpRecommend", t, func(ctx convey.C) {
  266. var (
  267. c = context.Background()
  268. mid = int64(2089809)
  269. arg = &model.SearchUpRecArg{ServiceArea: "reg_ok", Platform: "web"}
  270. buvid = ""
  271. )
  272. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  273. rs, trackID, err := d.UpRecommend(c, mid, arg, buvid)
  274. ctx.Convey("Then err should be nil.rs,trackID should not be nil.", func(ctx convey.C) {
  275. ctx.So(err, convey.ShouldBeNil)
  276. ctx.So(trackID, convey.ShouldNotBeNil)
  277. ctx.Printf("%+v", rs)
  278. })
  279. })
  280. })
  281. }
  282. func TestDaoSearchEgg(t *testing.T) {
  283. convey.Convey("SearchEgg", t, func(ctx convey.C) {
  284. var (
  285. c = context.Background()
  286. )
  287. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  288. data, err := d.SearchEgg(c)
  289. ctx.Convey("Then err should be nil.data should not be nil.", func(ctx convey.C) {
  290. ctx.So(err, convey.ShouldBeNil)
  291. ctx.So(data, convey.ShouldNotBeNil)
  292. })
  293. })
  294. })
  295. }