123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- package mcndao
- import (
- "go-common/app/interface/main/mcn/model/mcnmodel"
- "testing"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestMcndaoadd(t *testing.T) {
- convey.Convey("add", t, func(ctx convey.C) {
- var (
- v = &mcnmodel.McnGetRecommendPoolInfo{}
- s = &RecommendPoolCache{}
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- s.add(v)
- ctx.Convey("No return values", func(ctx convey.C) {
- })
- })
- })
- }
- func TestMcndaoLen(t *testing.T) {
- var (
- s = &RecommendDataSorter{}
- )
- convey.Convey("Len", t, func(ctx convey.C) {
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- p1 := s.Len()
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestMcndaoRecommendSortByFansDesc(t *testing.T) {
- convey.Convey("RecommendSortByFansDesc", t, func(ctx convey.C) {
- var (
- p1 = &mcnmodel.McnGetRecommendPoolInfo{}
- p2 = &mcnmodel.McnGetRecommendPoolInfo{}
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- p1 := RecommendSortByFansDesc(p1, p2)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestMcndaoRecommendSortByFansAsc(t *testing.T) {
- convey.Convey("RecommendSortByFansAsc", t, func(ctx convey.C) {
- var (
- p1 = &mcnmodel.McnGetRecommendPoolInfo{}
- p2 = &mcnmodel.McnGetRecommendPoolInfo{}
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- p1 := RecommendSortByFansAsc(p1, p2)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestMcndaoRecommendSortByMonthFansDesc(t *testing.T) {
- convey.Convey("RecommendSortByMonthFansDesc", t, func(ctx convey.C) {
- var (
- p1 = &mcnmodel.McnGetRecommendPoolInfo{}
- p2 = &mcnmodel.McnGetRecommendPoolInfo{}
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- p1 := RecommendSortByMonthFansDesc(p1, p2)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestMcndaoRecommendSortByArchiveCountDesc(t *testing.T) {
- convey.Convey("RecommendSortByArchiveCountDesc", t, func(ctx convey.C) {
- var (
- p1 = &mcnmodel.McnGetRecommendPoolInfo{}
- p2 = &mcnmodel.McnGetRecommendPoolInfo{}
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- p1 := RecommendSortByArchiveCountDesc(p1, p2)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestMcndaocacheKeyRecommend(t *testing.T) {
- convey.Convey("cacheKeyRecommend", t, func(ctx convey.C) {
- var (
- a1 = int64(0)
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- p1 := cacheKeyRecommend(a1)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestMcndaorawGetRecommendPool(t *testing.T) {
- convey.Convey("rawGetRecommendPool", t, func(ctx convey.C) {
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- res, err := d.rawGetRecommendPool()
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(len(res), convey.ShouldBeGreaterThanOrEqualTo, 0)
- })
- })
- })
- }
- func TestMcndaoloadRecommendPool(t *testing.T) {
- convey.Convey("loadRecommendPool", t, func(ctx convey.C) {
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- res, err := d.loadRecommendPool()
- 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 TestMcndaogetRecommendCache(t *testing.T) {
- convey.Convey("getRecommendCache", t, func(ctx convey.C) {
- var (
- keyCalc = cacheKeyRecommend
- load = d.loadRecommendPool
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- result, err := d.getRecommendCache(keyCalc, load)
- ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(result, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestMcndaoGetRecommendPool(t *testing.T) {
- convey.Convey("GetRecommendPool", t, func(ctx convey.C) {
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- res, err := d.GetRecommendPool()
- 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)
- })
- })
- })
- }
|