123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- package up
- import (
- "context"
- "testing"
- "go-common/app/admin/main/mcn/model"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestUpAddMcnUpRecommend(t *testing.T) {
- convey.Convey("AddMcnUpRecommend", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.McnUpRecommendPool{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rows, err := d.AddMcnUpRecommend(c, arg)
- d.db.Exec(c, "delete from mcn_up_recommend_pool where up_mid=0")
- ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(rows, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpUpMcnUpsRecommendOP(t *testing.T) {
- convey.Convey("UpMcnUpsRecommendOP", t, func(ctx convey.C) {
- var (
- c = context.Background()
- upMids = []int64{1, 2}
- state = model.MCNUPRecommendState(2)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rows, err := d.UpMcnUpsRecommendOP(c, upMids, state)
- ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(rows, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpMcnUpRecommends(t *testing.T) {
- convey.Convey("McnUpRecommends", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.MCNUPRecommendReq{}
- )
- arg.Order = "mtime"
- arg.Sort = "DESC"
- arg.Page = 1
- arg.Size = 10
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.McnUpRecommends(c, arg)
- 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 TestUpMcnUpRecommendTotal(t *testing.T) {
- convey.Convey("McnUpRecommendTotal", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.MCNUPRecommendReq{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- count, err := d.McnUpRecommendTotal(c, arg)
- ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(count, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpMcnUpBindMids(t *testing.T) {
- convey.Convey("McnUpBindMids", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mids = []int64{1, 2}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- bmids, err := d.McnUpBindMids(c, mids)
- ctx.Convey("Then err should be nil.bmids should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- if len(bmids) == 0 {
- ctx.So(bmids, convey.ShouldBeEmpty)
- } else {
- ctx.So(bmids, convey.ShouldNotBeNil)
- }
- })
- })
- })
- }
- func TestUpMcnUpRecommendMid(t *testing.T) {
- convey.Convey("McnUpRecommendMid", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mid = int64(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- m, err := d.McnUpRecommendMid(c, mid)
- ctx.Convey("Then err should be nil.m should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(m, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestUpbuildUpRecommendSQL(t *testing.T) {
- convey.Convey("buildUpRecommendSQL", t, func(ctx convey.C) {
- var (
- tp = ""
- arg = &model.MCNUPRecommendReq{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- sql, values := d.buildUpRecommendSQL(tp, arg)
- ctx.Convey("Then sql,values should not be nil.", func(ctx convey.C) {
- ctx.So(values, convey.ShouldNotBeNil)
- ctx.So(sql, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpjoinStringSQL(t *testing.T) {
- convey.Convey("joinStringSQL", t, func(ctx convey.C) {
- var (
- is = []string{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- p1 := d.joinStringSQL(is)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
|