123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- package dao
- import (
- "context"
- "go-common/app/service/video/stream-mng/model"
- "testing"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestDaogetStreamNamekey(t *testing.T) {
- convey.Convey("getStreamNamekey", t, func(ctx convey.C) {
- var (
- streamName = "live_19148701_6447624"
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- p1 := d.getStreamNamekey(streamName)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaogetRoomIDKey(t *testing.T) {
- convey.Convey("getRoomIDKey", t, func(ctx convey.C) {
- var (
- rid = int64(11891462)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- p1 := d.getRoomIDKey(rid)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaogetRoomFieldDefaultKey(t *testing.T) {
- convey.Convey("getRoomFieldDefaultKey", t, func(ctx convey.C) {
- var (
- streamName = "live_19148701_6447624"
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- p1 := d.getRoomFieldDefaultKey(streamName)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaogetRoomFieldOriginKey(t *testing.T) {
- convey.Convey("getRoomFieldOriginKey", t, func(ctx convey.C) {
- var (
- streamName = "live_19148701_6447624"
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- p1 := d.getRoomFieldOriginKey(streamName)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaogetRoomFieldForwardKey(t *testing.T) {
- convey.Convey("getRoomFieldForwardKey", t, func(ctx convey.C) {
- var (
- streamName = "live_19148701_6447624"
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- p1 := d.getRoomFieldForwardKey(streamName)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaogetRoomFieldSecretKey(t *testing.T) {
- convey.Convey("getRoomFieldSecretKey", t, func(ctx convey.C) {
- var (
- streamName = "live_19148701_6447624"
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- p1 := d.getRoomFieldSecretKey(streamName)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaogetLastCDNKey(t *testing.T) {
- convey.Convey("getLastCDNKey", t, func(ctx convey.C) {
- var (
- rid = int64(11891462)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- p1 := d.getLastCDNKey(rid)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaogetChangeSrcKey(t *testing.T) {
- convey.Convey("getChangeSrcKey", t, func(ctx convey.C) {
- var (
- rid = int64(11891462)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- p1 := d.getChangeSrcKey(rid)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoCacheStreamFullInfo(t *testing.T) {
- convey.Convey("CacheStreamFullInfo", t, func(ctx convey.C) {
- var (
- c = context.Background()
- rid = int64(11891462)
- sname = ""
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.CacheStreamFullInfo(c, rid, sname)
- 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 TestDaoAddCacheStreamFullInfo(t *testing.T) {
- convey.Convey("AddCacheStreamFullInfo", t, func(ctx convey.C) {
- var (
- c = context.Background()
- id = int64(11891462)
- stream = &model.StreamFullInfo{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.AddCacheStreamFullInfo(c, id, stream)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoCacheStreamRIDByName(t *testing.T) {
- convey.Convey("CacheStreamRIDByName", t, func(ctx convey.C) {
- var (
- c = context.Background()
- sname = "live_19148701_6447624"
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.CacheStreamRIDByName(c, sname)
- 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 TestDaoAddCacheStreamRIDByName(t *testing.T) {
- convey.Convey("AddCacheStreamRIDByName", t, func(ctx convey.C) {
- var (
- c = context.Background()
- sname = "live_19148701_6447624"
- stream = &model.StreamFullInfo{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.AddCacheStreamRIDByName(c, sname, stream)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoAddCacheMultiStreamInfo(t *testing.T) {
- convey.Convey("AddCacheMultiStreamInfo", t, func(ctx convey.C) {
- var (
- c = context.Background()
- res map[int64]*model.StreamFullInfo
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.AddCacheMultiStreamInfo(c, res)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoCacheMultiStreamInfo(t *testing.T) {
- convey.Convey("CacheMultiStreamInfo", t, func(ctx convey.C) {
- var (
- c = context.Background()
- rids = []int64{11891462}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.CacheMultiStreamInfo(c, rids)
- 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 TestDaoUpdateLastCDNCache(t *testing.T) {
- convey.Convey("UpdateLastCDNCache", t, func(ctx convey.C) {
- var (
- c = context.Background()
- rid = int64(11891462)
- origin = int64(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.UpdateLastCDNCache(c, rid, origin)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoUpdateChangeSrcCache(t *testing.T) {
- convey.Convey("UpdateChangeSrcCache", t, func(ctx convey.C) {
- var (
- c = context.Background()
- rid = int64(11891462)
- origin = int64(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.UpdateChangeSrcCache(c, rid, origin)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoGetLastCDNFromCache(t *testing.T) {
- convey.Convey("GetLastCDNFromCache", t, func(ctx convey.C) {
- var (
- c = context.Background()
- rid = int64(11891462)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- p1, err := d.GetLastCDNFromCache(c, rid)
- ctx.Convey("Then err should be nil.p1 should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoGetChangeSrcFromCache(t *testing.T) {
- convey.Convey("GetChangeSrcFromCache", t, func(ctx convey.C) {
- var (
- c = context.Background()
- rid = int64(11891462)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- p1, err := d.GetChangeSrcFromCache(c, rid)
- ctx.Convey("Then err should be nil.p1 should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoDeleteStreamByRIDFromCache(t *testing.T) {
- convey.Convey("DeleteStreamByRIDFromCache", t, func(ctx convey.C) {
- var (
- c = context.Background()
- rid = int64(11891462)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.DeleteStreamByRIDFromCache(c, rid)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoDeleteLastCDNFromCache(t *testing.T) {
- convey.Convey("DeleteLastCDNFromCache", t, func(ctx convey.C) {
- var (
- c = context.Background()
- rid = int64(11891462)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.DeleteLastCDNFromCache(c, rid)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
|