123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314 |
- package dao
- import (
- "context"
- "testing"
- "go-common/app/interface/main/web/model"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestDaoSearchAll(t *testing.T) {
- convey.Convey("SearchAll", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mid = int64(0)
- arg = &model.SearchAllArg{Pn: 1, Keyword: "test", Rid: 1}
- buvid = ""
- ua = ""
- )
- typ := model.WxSearchType
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.SearchAll(c, mid, arg, buvid, ua, typ)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoSearchVideo(t *testing.T) {
- convey.Convey("SearchVideo", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mid = int64(0)
- arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypeVideo, Keyword: "test"}
- buvid = ""
- ua = ""
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.SearchVideo(c, mid, arg, buvid, ua)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoSearchBangumi(t *testing.T) {
- convey.Convey("SearchBangumi", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mid = int64(0)
- arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypeBangumi, Keyword: "test"}
- buvid = ""
- ua = ""
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.SearchBangumi(c, mid, arg, buvid, ua)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoSearchPGC(t *testing.T) {
- convey.Convey("SearchPGC", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mid = int64(0)
- arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypePGC, Keyword: "test"}
- buvid = ""
- ua = ""
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.SearchPGC(c, mid, arg, buvid, ua)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoSearchLive(t *testing.T) {
- convey.Convey("SearchLive", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mid = int64(0)
- arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypeLive, Keyword: "test"}
- buvid = ""
- ua = ""
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.SearchLive(c, mid, arg, buvid, ua)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoSearchLiveRoom(t *testing.T) {
- convey.Convey("SearchLiveRoom", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mid = int64(0)
- arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypeLiveRoom, Keyword: "test"}
- buvid = ""
- ua = ""
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.SearchLiveRoom(c, mid, arg, buvid, ua)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoSearchLiveUser(t *testing.T) {
- convey.Convey("SearchLiveUser", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mid = int64(0)
- arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypeLiveUser, Keyword: "test"}
- buvid = ""
- ua = ""
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.SearchLiveUser(c, mid, arg, buvid, ua)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoSearchArticle(t *testing.T) {
- convey.Convey("SearchArticle", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mid = int64(0)
- arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypeArticle, Keyword: "test"}
- buvid = ""
- ua = ""
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.SearchArticle(c, mid, arg, buvid, ua)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoSearchSpecial(t *testing.T) {
- convey.Convey("SearchSpecial", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mid = int64(0)
- arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypeSpecial, Keyword: "test"}
- buvid = ""
- ua = ""
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.SearchSpecial(c, mid, arg, buvid, ua)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoSearchTopic(t *testing.T) {
- convey.Convey("SearchTopic", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mid = int64(0)
- arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypeTopic, Keyword: "test"}
- buvid = ""
- ua = ""
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.SearchTopic(c, mid, arg, buvid, ua)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoSearchUser(t *testing.T) {
- convey.Convey("SearchUser", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mid = int64(0)
- arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypeUser, Keyword: "test"}
- buvid = ""
- ua = ""
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.SearchUser(c, mid, arg, buvid, ua)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoSearchPhoto(t *testing.T) {
- convey.Convey("SearchPhoto", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mid = int64(0)
- arg = &model.SearchTypeArg{Pn: 1, SearchType: model.SearchTypePhoto, Keyword: "test"}
- buvid = ""
- ua = ""
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.SearchPhoto(c, mid, arg, buvid, ua)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoSearchRec(t *testing.T) {
- convey.Convey("SearchRec", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mid = int64(0)
- pn = int(1)
- ps = int(10)
- keyword = "test"
- fromSource = ""
- buvid = ""
- ua = ""
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.SearchRec(c, mid, pn, ps, keyword, fromSource, buvid, ua)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoSearchDefault(t *testing.T) {
- convey.Convey("SearchDefault", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mid = int64(0)
- fromSource = ""
- buvid = ""
- ua = ""
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- data, err := d.SearchDefault(c, mid, fromSource, buvid, ua)
- ctx.Convey("Then err should be nil.data should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(data, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoUpRecommend(t *testing.T) {
- convey.Convey("UpRecommend", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mid = int64(2089809)
- arg = &model.SearchUpRecArg{ServiceArea: "reg_ok", Platform: "web"}
- buvid = ""
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rs, trackID, err := d.UpRecommend(c, mid, arg, buvid)
- ctx.Convey("Then err should be nil.rs,trackID should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(trackID, convey.ShouldNotBeNil)
- ctx.Printf("%+v", rs)
- })
- })
- })
- }
- func TestDaoSearchEgg(t *testing.T) {
- convey.Convey("SearchEgg", t, func(ctx convey.C) {
- var (
- c = context.Background()
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- data, err := d.SearchEgg(c)
- ctx.Convey("Then err should be nil.data should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(data, convey.ShouldNotBeNil)
- })
- })
- })
- }
|