123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395 |
- package fav
- import (
- "context"
- favmdl "go-common/app/service/main/favorite/model"
- xtime "go-common/library/time"
- "testing"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestFavcntHit(t *testing.T) {
- convey.Convey("cntHit", t, func(ctx convey.C) {
- var (
- mid = int64(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- p1 := cntHit(mid)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestFavfolderHit(t *testing.T) {
- convey.Convey("folderHit", t, func(ctx convey.C) {
- var (
- mid = int64(1)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- p1 := folderHit(mid)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestFavrelationHit(t *testing.T) {
- convey.Convey("relationHit", t, func(ctx convey.C) {
- var (
- mid = int64(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- p1 := relationHit(mid)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestFavusersHit(t *testing.T) {
- convey.Convey("usersHit", t, func(ctx convey.C) {
- var (
- oid = int64(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- p1 := usersHit(oid)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestFavPingMySQL(t *testing.T) {
- convey.Convey("PingMySQL", t, func(ctx convey.C) {
- var (
- c = context.Background()
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.pingMySQL(c)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestRecentFolder(t *testing.T) {
- convey.Convey("Folder Recents", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mid = int64(0)
- fid = int64(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- _, err := d.RecentRes(c, mid, fid)
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestUpdateFavSequence(t *testing.T) {
- convey.Convey("Test Update Sequence", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mid = int64(0)
- fid = int64(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- t, err := d.BeginTran(c)
- ctx.So(err, convey.ShouldBeNil)
- _, err = d.TxUpdateFavSequence(t, mid, fid, 1, 2, 123, xtime.Time(0))
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestFavFolder(t *testing.T) {
- convey.Convey("Folder", t, func(ctx convey.C) {
- var (
- c = context.Background()
- tp = int8(0)
- mid = int64(0)
- fid = int64(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- _, err := d.Folder(c, tp, mid, fid)
- ctx.Convey("Then err should be nil.f should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestFavUpFolderCnt(t *testing.T) {
- convey.Convey("UpFolderCnt", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mid = int64(0)
- fid = int64(0)
- cnt = int(0)
- now xtime.Time
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rows, err := d.UpFolderCnt(c, mid, fid, cnt, now)
- 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 TestFavRelation(t *testing.T) {
- convey.Convey("Relation", t, func(ctx convey.C) {
- var (
- c = context.Background()
- tp = int8(0)
- mid = int64(0)
- fid = int64(0)
- oid = int64(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- _, err := d.Relation(c, tp, mid, fid, oid)
- ctx.Convey("Then err should be nil.m should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestFavRelations(t *testing.T) {
- convey.Convey("Relations", t, func(ctx convey.C) {
- var (
- c = context.Background()
- typ = int8(0)
- mid = int64(0)
- fid = int64(0)
- mtime xtime.Time
- limit = int(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- fr, err := d.Relations(c, typ, mid, fid, mtime, limit)
- ctx.Convey("Then err should be nil.fr should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(fr, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestFavRelationFidsByOid(t *testing.T) {
- convey.Convey("RelationFidsByOid", t, func(ctx convey.C) {
- var (
- c = context.Background()
- tp = int8(0)
- mid = int64(0)
- oid = int64(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- _, err := d.RelationFidsByOid(c, tp, mid, oid)
- ctx.Convey("Then err should be nil.fids should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestFavRelationCnt(t *testing.T) {
- convey.Convey("RelationCnt", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mid = int64(0)
- fid = int64(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- cnt, err := d.RelationCnt(c, mid, fid)
- ctx.Convey("Then err should be nil.cnt should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(cnt, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestFavAddRelation(t *testing.T) {
- convey.Convey("AddRelation", t, func(ctx convey.C) {
- var (
- c = context.Background()
- fr = &favmdl.Favorite{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rows, err := d.AddRelation(c, fr)
- 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 TestFavDelRelation(t *testing.T) {
- convey.Convey("DelRelation", t, func(ctx convey.C) {
- var (
- c = context.Background()
- tp = int8(0)
- mid = int64(0)
- fid = int64(0)
- oid = int64(0)
- now xtime.Time
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rows, err := d.DelRelation(c, tp, mid, fid, oid, now)
- 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 TestFavUpStatCnt(t *testing.T) {
- convey.Convey("UpStatCnt", t, func(ctx convey.C) {
- var (
- c = context.Background()
- tp = int8(0)
- oid = int64(0)
- incr = int(0)
- now xtime.Time
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rows, err := d.UpStatCnt(c, tp, oid, incr, now)
- 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 TestFavStatCnt(t *testing.T) {
- convey.Convey("StatCnt", t, func(ctx convey.C) {
- var (
- c = context.Background()
- tp = int8(0)
- oid = int64(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- cnt, err := d.StatCnt(c, tp, oid)
- ctx.Convey("Then err should be nil.cnt should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(cnt, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestFavRelationFids(t *testing.T) {
- convey.Convey("RelationFids", t, func(ctx convey.C) {
- var (
- c = context.Background()
- tp = int8(0)
- mid = int64(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rfids, err := d.RelationFids(c, tp, mid)
- ctx.Convey("Then err should be nil.rfids should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(rfids, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestFavOidsByFid(t *testing.T) {
- convey.Convey("OidsByFid", t, func(ctx convey.C) {
- var (
- c = context.Background()
- typ = int8(0)
- mid = int64(0)
- fid = int64(0)
- offset = int(0)
- limit = int(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- oids, err := d.OidsByFid(c, typ, mid, fid, offset, limit)
- ctx.Convey("Then err should be nil.oids should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(oids, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestFavDelRelationsByOids(t *testing.T) {
- convey.Convey("DelRelationsByOids", t, func(ctx convey.C) {
- var (
- c = context.Background()
- typ = int8(0)
- mid = int64(0)
- fid = int64(0)
- oids = []int64{}
- now xtime.Time
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rows, err := d.DelRelationsByOids(c, typ, mid, fid, oids, now)
- 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 TestFavAddUser(t *testing.T) {
- convey.Convey("AddUser", t, func(ctx convey.C) {
- var (
- c = context.Background()
- u = &favmdl.User{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rows, err := d.AddUser(c, u)
- 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 TestFavDelUser(t *testing.T) {
- convey.Convey("DelUser", t, func(ctx convey.C) {
- var (
- c = context.Background()
- u = &favmdl.User{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rows, err := d.DelUser(c, u)
- 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 TestRelationsByOids(t *testing.T) {
- convey.Convey("RelationsByOids", t, func(ctx convey.C) {
- var (
- c = context.Background()
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- favs, err := d.RelationsByOids(c, 2, 1501, 168, []int64{10108138})
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(favs, convey.ShouldNotBeNil)
- _, err = d.BatchUpdateSeq(c, 76, favs)
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
|