123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592 |
- package dao
- import (
- "context"
- "testing"
- "go-common/app/service/main/favorite/model"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestFavfolderHit(t *testing.T) {
- var (
- mid = int64(0)
- )
- convey.Convey("folderHit", t, 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) {
- var (
- mid = int64(0)
- )
- convey.Convey("relationHit", t, 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) {
- var (
- oid = int64(0)
- )
- convey.Convey("usersHit", t, 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 TestFavcountHit(t *testing.T) {
- var (
- oid = int64(0)
- )
- convey.Convey("countHit", t, func(ctx convey.C) {
- p1 := countHit(oid)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- }
- func TestFavpingMySQL(t *testing.T) {
- var (
- c = context.TODO()
- )
- convey.Convey("pingMySQL", t, 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 TestFavFolder(t *testing.T) {
- var (
- c = context.TODO()
- tp = int8(1)
- mid = int64(88888894)
- fid = int64(1)
- )
- convey.Convey("Folder", t, func(ctx convey.C) {
- f, 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)
- ctx.So(f, convey.ShouldNotBeNil)
- })
- })
- }
- func TestFavFolderByName(t *testing.T) {
- var (
- c = context.TODO()
- tp = int8(0)
- mid = int64(0)
- name = ""
- )
- convey.Convey("FolderByName", t, func(ctx convey.C) {
- f, err := d.FolderByName(c, tp, mid, name)
- ctx.Convey("Then err should be nil.f should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(f, convey.ShouldNotBeNil)
- })
- })
- }
- func TestFavDefaultFolder(t *testing.T) {
- var (
- c = context.TODO()
- tp = int8(0)
- mid = int64(0)
- )
- convey.Convey("DefaultFolder", t, func(ctx convey.C) {
- f, err := d.DefaultFolder(c, tp, mid)
- ctx.Convey("Then err should be nil.f should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(f, convey.ShouldNotBeNil)
- })
- })
- }
- func TestFavAddFolder(t *testing.T) {
- var (
- c = context.TODO()
- f = &model.Folder{}
- )
- convey.Convey("AddFolder", t, func(ctx convey.C) {
- fid, err := d.AddFolder(c, f)
- ctx.Convey("Then err should be nil.fid should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(fid, convey.ShouldNotBeNil)
- })
- })
- }
- func TestFavUpdateFolder(t *testing.T) {
- var (
- c = context.TODO()
- f = &model.Folder{}
- )
- convey.Convey("UpdateFolder", t, func(ctx convey.C) {
- fid, err := d.UpdateFolder(c, f)
- ctx.Convey("Then err should be nil.fid should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(fid, convey.ShouldNotBeNil)
- })
- })
- }
- func TestFavUpFolderName(t *testing.T) {
- var (
- c = context.TODO()
- typ = int8(0)
- mid = int64(0)
- fid = int64(0)
- name = ""
- )
- convey.Convey("UpFolderName", t, func(ctx convey.C) {
- rows, err := d.UpFolderName(c, typ, mid, fid, name)
- 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 TestFavUpFolderAttr(t *testing.T) {
- var (
- c = context.TODO()
- typ = int8(0)
- mid = int64(0)
- fid = int64(0)
- attr = int32(0)
- )
- convey.Convey("UpFolderAttr", t, func(ctx convey.C) {
- rows, err := d.UpFolderAttr(c, typ, mid, fid, attr)
- 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 TestFavFolderRelations(t *testing.T) {
- var (
- c = context.TODO()
- typ = int8(0)
- mid = int64(0)
- fid = int64(0)
- start = int(0)
- end = int(0)
- )
- convey.Convey("FolderRelations", t, func(ctx convey.C) {
- fr, err := d.FolderRelations(c, typ, mid, fid, start, end)
- 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 TestFavFolders(t *testing.T) {
- var (
- c = context.TODO()
- fvmids = []*model.ArgFVmid{}
- )
- convey.Convey("Folders", t, func(ctx convey.C) {
- fs, err := d.Folders(c, fvmids)
- ctx.Convey("Then err should be nil.fs should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(fs, convey.ShouldNotBeNil)
- })
- })
- }
- func TestFavRelationFidsByOid(t *testing.T) {
- var (
- c = context.TODO()
- tp = int8(1)
- mid = int64(88888894)
- oid = int64(1)
- )
- convey.Convey("RelationFidsByOid", t, 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 TestFavRelationFidsByOids(t *testing.T) {
- var (
- c = context.TODO()
- tp = int8(1)
- mid = int64(8888894)
- oids = []int64{1, 2, 3}
- )
- convey.Convey("RelationFidsByOids", t, func(ctx convey.C) {
- fidsMap, err := d.RelationFidsByOids(c, tp, mid, oids)
- ctx.Convey("Then err should be nil.fidsMap should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(fidsMap, convey.ShouldNotBeNil)
- })
- })
- }
- func TestFavCntRelations(t *testing.T) {
- var (
- c = context.TODO()
- mid = int64(0)
- fid = int64(0)
- )
- convey.Convey("CntRelations", t, func(ctx convey.C) {
- count, err := d.CntRelations(c, mid, fid, 2)
- 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 TestFavFolderCnt(t *testing.T) {
- var (
- c = context.TODO()
- tp = int8(0)
- mid = int64(0)
- )
- convey.Convey("FolderCnt", t, func(ctx convey.C) {
- count, err := d.FolderCnt(c, tp, mid)
- 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 TestFavAddFav(t *testing.T) {
- var (
- c = context.TODO()
- fr = &model.Favorite{}
- )
- convey.Convey("AddFav", t, func(ctx convey.C) {
- rows, err := d.AddFav(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 TestFavDelFav(t *testing.T) {
- var (
- c = context.TODO()
- tp = int8(0)
- mid = int64(0)
- fid = int64(0)
- oid = int64(0)
- )
- convey.Convey("DelFav", t, func(ctx convey.C) {
- rows, err := d.DelFav(c, tp, mid, fid, oid)
- 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 TestFavAddRelation(t *testing.T) {
- var (
- c = context.TODO()
- fr = &model.Favorite{}
- )
- convey.Convey("AddRelation", t, 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 TestFavRelation(t *testing.T) {
- var (
- c = context.TODO()
- tp = int8(0)
- mid = int64(0)
- fid = int64(0)
- oid = int64(0)
- )
- convey.Convey("Relation", t, 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 TestFavDelRelation(t *testing.T) {
- var (
- c = context.TODO()
- tp = int8(0)
- mid = int64(0)
- fid = int64(0)
- oid = int64(0)
- )
- convey.Convey("DelRelation", t, func(ctx convey.C) {
- rows, err := d.DelRelation(c, tp, mid, fid, oid)
- 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 TestFavMultiDelRelations(t *testing.T) {
- var (
- c = context.TODO()
- tp = int8(1)
- mid = int64(88888894)
- fid = int64(0)
- oids = []int64{1, 2, 3}
- )
- convey.Convey("MultiDelRelations", t, func(ctx convey.C) {
- rows, err := d.MultiDelRelations(c, tp, mid, fid, oids)
- 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 TestFavTxMultiDelRelations(t *testing.T) {
- var (
- tx, _ = d.BeginTran(context.TODO())
- tp = int8(1)
- mid = int64(88888894)
- fid = int64(0)
- oids = []int64{1, 2, 3}
- )
- convey.Convey("TxMultiDelRelations", t, func(ctx convey.C) {
- rows, err := d.TxMultiDelRelations(tx, tp, mid, fid, oids)
- 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 TestFavMultiAddRelations(t *testing.T) {
- var (
- c = context.TODO()
- tp = int8(1)
- mid = int64(88888894)
- fid = int64(0)
- oids = []int64{1}
- )
- convey.Convey("MultiAddRelations", t, func(ctx convey.C) {
- rows, err := d.MultiAddRelations(c, tp, mid, fid, oids)
- 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 TestFavDelFolder(t *testing.T) {
- var (
- c = context.TODO()
- tp = int8(0)
- mid = int64(0)
- fid = int64(0)
- )
- convey.Convey("DelFolder", t, func(ctx convey.C) {
- rows, err := d.DelFolder(c, tp, mid, fid)
- 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 TestFavUserFolders(t *testing.T) {
- var (
- c = context.TODO()
- typ = int8(0)
- mid = int64(0)
- )
- convey.Convey("UserFolders", t, func(ctx convey.C) {
- fs, err := d.UserFolders(c, typ, mid)
- ctx.Convey("Then err should be nil.fs should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(fs, convey.ShouldNotBeNil)
- })
- })
- }
- func TestFavFolderSort(t *testing.T) {
- var (
- c = context.TODO()
- typ = int8(0)
- mid = int64(0)
- )
- convey.Convey("FolderSort", t, func(ctx convey.C) {
- fst, err := d.FolderSort(c, typ, mid)
- ctx.Convey("Then err should be nil.fst should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(fst, convey.ShouldNotBeNil)
- })
- })
- }
- func TestFavUpFolderSort(t *testing.T) {
- var (
- c = context.TODO()
- fst = &model.FolderSort{}
- )
- convey.Convey("UpFolderSort", t, func(ctx convey.C) {
- rows, err := d.UpFolderSort(c, fst)
- 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 TestFavRecentOids(t *testing.T) {
- var (
- c = context.TODO()
- mid = int64(88888894)
- fid = int64(1)
- )
- convey.Convey("RecentOids", t, func(ctx convey.C) {
- oids, err := d.RecentOids(c, mid, fid, 1)
- 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 TestFavTxCopyRelations(t *testing.T) {
- var (
- tx, _ = d.BeginTran(context.TODO())
- typ = int8(1)
- oldmid = int64(88888894)
- mid = int64(88888894)
- oldfid = int64(0)
- newfid = int64(0)
- oids = []int64{1}
- )
- convey.Convey("TxCopyRelations", t, func(ctx convey.C) {
- rows, err := d.TxCopyRelations(tx, typ, oldmid, mid, oldfid, newfid, oids)
- 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 TestFavCopyRelations(t *testing.T) {
- var (
- c = context.TODO()
- typ = int8(1)
- oldmid = int64(88888894)
- mid = int64(88888894)
- oldfid = int64(0)
- newfid = int64(0)
- oids = []int64{1}
- )
- convey.Convey("CopyRelations", t, func(ctx convey.C) {
- rows, err := d.CopyRelations(c, typ, oldmid, mid, oldfid, newfid, oids)
- 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 TestFavCntUsers(t *testing.T) {
- var (
- c = context.TODO()
- typ = int8(0)
- oid = int64(0)
- )
- convey.Convey("CntUsers", t, func(ctx convey.C) {
- count, err := d.CntUsers(c, typ, oid)
- 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 TestFavUsers(t *testing.T) {
- var (
- c = context.TODO()
- typ = int8(0)
- oid = int64(0)
- start = int(0)
- end = int(0)
- )
- convey.Convey("Users", t, func(ctx convey.C) {
- us, err := d.Users(c, typ, oid, start, end)
- ctx.Convey("Then err should be nil.us should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(us, convey.ShouldNotBeNil)
- })
- })
- }
- func TestFavOidCount(t *testing.T) {
- var (
- c = context.TODO()
- typ = int8(0)
- oid = int64(0)
- )
- convey.Convey("OidCount", t, func(ctx convey.C) {
- count, err := d.OidCount(c, typ, oid)
- 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 TestFavOidsCount(t *testing.T) {
- var (
- c = context.TODO()
- typ = int8(1)
- oids = []int64{1, 2, 3}
- )
- convey.Convey("OidsCount", t, func(ctx convey.C) {
- counts, err := d.OidsCount(c, typ, oids)
- ctx.Convey("Then err should be nil.counts should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(counts, convey.ShouldNotBeNil)
- })
- })
- }
- func TestFavBatchOids(t *testing.T) {
- var (
- c = context.TODO()
- typ = int8(1)
- mid = int64(88888894)
- limit = int(10)
- )
- convey.Convey("BatchOids", t, func(ctx convey.C) {
- oids, err := d.BatchOids(c, typ, mid, 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)
- })
- })
- }
|