123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- package dao
- import (
- "context"
- "testing"
- "go-common/app/interface/main/playlist/model"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestDaokeyStat(t *testing.T) {
- var (
- mid = int64(2)
- )
- convey.Convey("keyStat", t, func(ctx convey.C) {
- p1 := keyStat(mid)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaokeyPl(t *testing.T) {
- var (
- pid = int64(1)
- )
- convey.Convey("keyPl", t, func(ctx convey.C) {
- p1 := keyPl(pid)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoPlStatCache(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(2)
- pid = int64(1)
- )
- convey.Convey("PlStatCache", t, func(ctx convey.C) {
- _, err := d.PlStatCache(c, mid, pid)
- ctx.Convey("Then err should be nil.stat should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoSetPlStatCache(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(2)
- pid = int64(1)
- stat = &model.PlStat{}
- )
- convey.Convey("SetPlStatCache", t, func(ctx convey.C) {
- err := d.SetPlStatCache(c, mid, pid, stat)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoSetStatsCache(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(2)
- plStats = []*model.PlStat{}
- )
- plStats = append(plStats, &model.PlStat{ID: 1, Share: 1})
- convey.Convey("SetStatsCache", t, func(ctx convey.C) {
- err := d.SetStatsCache(c, mid, plStats)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoPlsCache(t *testing.T) {
- var (
- c = context.Background()
- pids = []int64{1, 2, 3}
- )
- convey.Convey("PlsCache", t, func(ctx convey.C) {
- res, err := d.PlsCache(c, pids)
- 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 TestDaoSetPlCache(t *testing.T) {
- var (
- c = context.Background()
- plStats = []*model.PlStat{}
- )
- plStats = append(plStats, &model.PlStat{ID: 1, View: 100})
- convey.Convey("SetPlCache", t, func(ctx convey.C) {
- err := d.SetPlCache(c, plStats)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoDelPlCache(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(2)
- pid = int64(1)
- )
- convey.Convey("DelPlCache", t, func(ctx convey.C) {
- err := d.DelPlCache(c, mid, pid)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoStatsCache(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(2)
- )
- convey.Convey("StatsCache", t, func(ctx convey.C) {
- _, err := d.StatsCache(c, mid)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
|