wild_test.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package search
  2. import (
  3. "context"
  4. "testing"
  5. mdlSearch "go-common/app/interface/main/tv/model/search"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestSearchUserSearch(t *testing.T) {
  9. convey.Convey("UserSearch", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. arg = &mdlSearch.UserSearch{
  13. Keyword: "lex",
  14. Build: "111",
  15. SearchType: "bili_user",
  16. Page: 1,
  17. Pagesize: 20,
  18. }
  19. )
  20. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  21. user, err := d.UserSearch(c, arg)
  22. ctx.Convey("Then err should be nil.user should not be nil.", func(ctx convey.C) {
  23. ctx.So(err, convey.ShouldBeNil)
  24. ctx.So(user, convey.ShouldNotBeNil)
  25. })
  26. })
  27. })
  28. }
  29. func TestSearchSearchAllWild(t *testing.T) {
  30. convey.Convey("SearchAllWild", t, func(ctx convey.C) {
  31. var (
  32. c = context.Background()
  33. arg = &mdlSearch.UserSearch{
  34. Keyword: "工作细胞",
  35. Build: "111",
  36. SearchType: "all",
  37. Page: 1,
  38. Pagesize: 20,
  39. }
  40. )
  41. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  42. user, err := d.SearchAllWild(c, arg)
  43. ctx.Convey("Then err should be nil.user should not be nil.", func(ctx convey.C) {
  44. ctx.So(err, convey.ShouldBeNil)
  45. ctx.So(user, convey.ShouldNotBeNil)
  46. })
  47. })
  48. })
  49. }
  50. func TestSearchPgcSearch(t *testing.T) {
  51. convey.Convey("PgcSearch", t, func(ctx convey.C) {
  52. var (
  53. c = context.Background()
  54. arg = &mdlSearch.UserSearch{
  55. Keyword: "白兔糖",
  56. Build: "111",
  57. SearchType: "all",
  58. Page: 1,
  59. Pagesize: 20,
  60. }
  61. )
  62. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  63. st, err := d.PgcSearch(c, arg)
  64. ctx.Convey("Then err should be nil.st should not be nil.", func(ctx convey.C) {
  65. ctx.So(err, convey.ShouldBeNil)
  66. ctx.So(st, convey.ShouldNotBeNil)
  67. })
  68. })
  69. })
  70. }