123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344 |
- package cms
- import (
- "context"
- "fmt"
- "testing"
- "go-common/app/interface/main/tv/model"
- "go-common/library/database/sql"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestCmsVideoMetaDB(t *testing.T) {
- var (
- c = context.Background()
- cid = int64(0)
- )
- convey.Convey("VideoMetaDB", t, func(ctx convey.C) {
- ctx.Convey("Then err should be nil.meta should not be nil.", func(ctx convey.C) {
- sids, err := pickIDs(d.db, _pickCids)
- if err != nil || len(sids) == 0 {
- fmt.Println("Empty Sids ", err)
- return
- }
- cid = sids[0]
- meta, err := d.VideoMetaDB(c, cid)
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(meta, convey.ShouldNotBeNil)
- })
- ctx.Convey("Db Error", func(ctx convey.C) {
- d.db.Close()
- _, err := d.VideoMetaDB(c, cid)
- ctx.So(err, convey.ShouldNotBeNil)
- d.db = sql.NewMySQL(d.conf.Mysql)
- })
- })
- }
- func TestCmsArcMetaDB(t *testing.T) {
- var (
- c = context.Background()
- aid = int64(0)
- )
- convey.Convey("ArcMetaDB", t, func(ctx convey.C) {
- ctx.Convey("Then err should be nil.meta should not be nil.", func(ctx convey.C) {
- sids, err := pickIDs(d.db, _pickAids)
- if err != nil || len(sids) == 0 {
- fmt.Println("Empty Sids ", err)
- return
- }
- aid = sids[0]
- meta, err := d.ArcMetaDB(c, aid)
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(meta, convey.ShouldNotBeNil)
- })
- ctx.Convey("Db Error", func(ctx convey.C) {
- d.db.Close()
- _, err := d.ArcMetaDB(c, aid)
- ctx.So(err, convey.ShouldNotBeNil)
- d.db = sql.NewMySQL(d.conf.Mysql)
- })
- })
- }
- func TestCmsVideoMetas(t *testing.T) {
- var (
- c = context.Background()
- cids = []int64{}
- err error
- )
- convey.Convey("VideoMetas", t, func(ctx convey.C) {
- ctx.Convey("Then err should be nil.meta should not be nil.", func(ctx convey.C) {
- if cids, err = pickIDs(d.db, _pickCids); err != nil || len(cids) == 0 {
- fmt.Println("Empty Sids ", err)
- return
- }
- meta, err := d.VideoMetas(c, cids)
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(meta, convey.ShouldNotBeNil)
- })
- ctx.Convey("Db Error", func(ctx convey.C) {
- d.db.Close()
- _, err := d.VideoMetas(c, cids)
- ctx.So(err, convey.ShouldNotBeNil)
- d.db = sql.NewMySQL(d.conf.Mysql)
- })
- })
- }
- func TestCmsArcMetas(t *testing.T) {
- var (
- c = context.Background()
- aids = []int64{}
- err error
- )
- convey.Convey("ArcMetas", t, func(ctx convey.C) {
- ctx.Convey("Then err should be nil.metas should not be nil.", func(ctx convey.C) {
- if aids, err = pickIDs(d.db, _pickAids); err != nil || len(aids) == 0 {
- fmt.Println("Empty Sids ", err)
- return
- }
- metas, err := d.ArcMetas(c, aids)
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(metas, convey.ShouldNotBeNil)
- })
- ctx.Convey("Db Error", func(ctx convey.C) {
- d.db.Close()
- _, err := d.ArcMetas(c, aids)
- ctx.So(err, convey.ShouldNotBeNil)
- d.db = sql.NewMySQL(d.conf.Mysql)
- })
- })
- }
- func TestCmsSeasonMetas(t *testing.T) {
- var (
- c = context.Background()
- sids = []int64{}
- err error
- )
- convey.Convey("SeasonMetas", t, func(ctx convey.C) {
- ctx.Convey("Then err should be nil.metas should not be nil.", func(ctx convey.C) {
- if sids, err = pickIDs(d.db, _pickSids); err != nil || len(sids) == 0 {
- fmt.Println("Empty Sids ", err)
- return
- }
- metas, err := d.SeasonMetas(c, sids)
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(metas, convey.ShouldNotBeNil)
- })
- ctx.Convey("Db Error", func(ctx convey.C) {
- d.db.Close()
- _, err := d.SeasonMetas(c, sids)
- ctx.So(err, convey.ShouldNotBeNil)
- d.db = sql.NewMySQL(d.conf.Mysql)
- })
- })
- }
- func TestCmsNewestOrder(t *testing.T) {
- var (
- c = context.Background()
- sid = int64(0)
- )
- convey.Convey("NewestOrder", t, func(ctx convey.C) {
- ctx.Convey("Then err should be nil.epid,newestOrder should not be nil.", func(ctx convey.C) {
- epid, newestOrder, err := d.NewestOrder(c, sid)
- if err != nil {
- ctx.So(err, convey.ShouldEqual, sql.ErrNoRows)
- } else {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(newestOrder, convey.ShouldNotBeNil)
- ctx.So(epid, convey.ShouldNotBeNil)
- }
- })
- })
- }
- func TestCmsEpMetas(t *testing.T) {
- var (
- c = context.Background()
- epids = []int64{}
- err error
- )
- convey.Convey("EpMetas", t, func(ctx convey.C) {
- ctx.Convey("Then err should be nil.metas should not be nil.", func(ctx convey.C) {
- if epids, err = pickIDs(d.db, _pickEpids); err != nil || len(epids) == 0 {
- fmt.Println("Empty epids ", err)
- return
- }
- metas, err := d.EpMetas(c, epids)
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(metas, convey.ShouldNotBeNil)
- })
- ctx.Convey("Db Error", func(ctx convey.C) {
- d.db.Close()
- _, err := d.EpMetas(c, epids)
- ctx.So(err, convey.ShouldNotBeNil)
- d.db = sql.NewMySQL(d.conf.Mysql)
- })
- })
- }
- func TestCmsEpAuthDB(t *testing.T) {
- var (
- c = context.Background()
- epid = int64(0)
- )
- convey.Convey("EpAuthDB", t, func(ctx convey.C) {
- ctx.Convey("Then err should be nil.ep should not be nil.", func(ctx convey.C) {
- epids, err := pickIDs(d.db, _pickEpids)
- if err != nil || len(epids) == 0 {
- fmt.Println("Empty epids ", err)
- return
- }
- epid = epids[0]
- ep, err := d.EpAuthDB(c, epid)
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(ep, convey.ShouldNotBeNil)
- })
- ctx.Convey("Db Error", func(ctx convey.C) {
- d.db.Close()
- _, err := d.EpAuthDB(c, epid)
- ctx.So(err, convey.ShouldNotBeNil)
- d.db = sql.NewMySQL(d.conf.Mysql)
- })
- })
- }
- func TestCmsSnAuthDB(t *testing.T) {
- var (
- c = context.Background()
- sids []int64
- sid int64
- err error
- )
- convey.Convey("SnAuthDB", t, func(ctx convey.C) {
- ctx.Convey("Then err should be nil.s should not be nil.", func(ctx convey.C) {
- if sids, err = pickIDs(d.db, _pickSids); err != nil || len(sids) == 0 {
- fmt.Println("Empty Sids ", err)
- return
- }
- sid = sids[0]
- s, err := d.SnAuthDB(c, sid)
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(s, convey.ShouldNotBeNil)
- })
- ctx.Convey("Db Error", func(ctx convey.C) {
- d.db.Close()
- _, err := d.SnAuthDB(c, sid)
- ctx.So(err, convey.ShouldNotBeNil)
- d.db = sql.NewMySQL(d.conf.Mysql)
- })
- })
- }
- func TestCmsSnsAuthDB(t *testing.T) {
- var (
- c = context.Background()
- sids []int64
- err error
- snsAuth map[int64]*model.SnAuth
- )
- convey.Convey("SnsAuthDB", t, func(ctx convey.C) {
- ctx.Convey("Then err should be nil.snsAuth should not be nil.", func(ctx convey.C) {
- if sids, err = pickIDs(d.db, _pickSids); err != nil || len(sids) == 0 {
- fmt.Println("Empty Sids ", err)
- return
- }
- snsAuth, err = d.SnsAuthDB(c, sids)
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(snsAuth, convey.ShouldNotBeNil)
- })
- ctx.Convey("Db Error", func(ctx convey.C) {
- d.db.Close()
- _, err = d.SnsAuthDB(c, sids)
- ctx.So(err, convey.ShouldNotBeNil)
- d.db = sql.NewMySQL(d.conf.Mysql)
- })
- })
- }
- func TestCmsEpsAuthDB(t *testing.T) {
- var (
- c = context.Background()
- epids []int64
- err error
- epsAuth map[int64]*model.EpAuth
- )
- convey.Convey("EpsAuthDB", t, func(ctx convey.C) {
- ctx.Convey("Then err should be nil.epsAuth should not be nil.", func(ctx convey.C) {
- epids, err = pickIDs(d.db, _pickEpids)
- if err != nil || len(epids) == 0 {
- fmt.Println("Empty epids ", err)
- return
- }
- epsAuth, err = d.EpsAuthDB(c, epids)
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(epsAuth, convey.ShouldNotBeNil)
- })
- ctx.Convey("Db Error", func(ctx convey.C) {
- d.db.Close()
- _, err = d.EpsAuthDB(c, epids)
- ctx.So(err, convey.ShouldNotBeNil)
- d.db = sql.NewMySQL(d.conf.Mysql)
- })
- })
- }
- func TestCmsSeasonCMS(t *testing.T) {
- var (
- c = context.Background()
- sids []int64
- sid = int64(0)
- err error
- season *model.SeasonCMS
- )
- convey.Convey("SeasonCMS", t, func(ctx convey.C) {
- ctx.Convey("Then err should be nil.season should not be nil.", func(ctx convey.C) {
- sids, err = pickIDs(d.db, _pickSids)
- if err != nil || len(sids) == 0 {
- fmt.Println("Empty Sids ", err)
- return
- }
- sid = sids[0]
- season, err = d.SeasonCMS(c, sid)
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(season, convey.ShouldNotBeNil)
- })
- ctx.Convey("Db Error", func(ctx convey.C) {
- d.db.Close()
- _, err = d.SeasonCMS(c, sid)
- ctx.So(err, convey.ShouldNotBeNil)
- d.db = sql.NewMySQL(d.conf.Mysql)
- })
- })
- }
- func TestCmsEpCMS(t *testing.T) {
- var (
- c = context.Background()
- epid = int64(0)
- )
- convey.Convey("EpCMS", t, func(ctx convey.C) {
- ctx.Convey("Then err should be nil.ep should not be nil.", func(ctx convey.C) {
- epids, err := pickIDs(d.db, _pickEpids)
- if err != nil || len(epids) == 0 {
- fmt.Println("Empty epids ", err)
- return
- }
- epid = epids[0]
- ep, err := d.EpCMS(c, epid)
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(ep, convey.ShouldNotBeNil)
- })
- ctx.Convey("Db Error", func(ctx convey.C) {
- d.db.Close()
- _, err := d.EpCMS(c, epid)
- ctx.So(err, convey.ShouldNotBeNil)
- d.db = sql.NewMySQL(d.conf.Mysql)
- })
- })
- }
|