123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521 |
- package dao
- import (
- "context"
- "testing"
- "go-common/app/service/main/member/model"
- "go-common/library/time"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestDaohit(t *testing.T) {
- var (
- id = int64(0)
- )
- convey.Convey("hit", t, func(ctx convey.C) {
- p1 := hit(id)
- ctx.Convey("p1 should not be nil", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoBeginTran(t *testing.T) {
- var (
- c = context.Background()
- )
- convey.Convey("BeginTran", t, func(ctx convey.C) {
- tx, err := d.BeginTran(c)
- defer tx.Commit()
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- ctx.Convey("tx should not be nil", func(ctx convey.C) {
- ctx.So(tx, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoBaseInfo(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(0)
- )
- convey.Convey("BaseInfo", t, func(ctx convey.C) {
- r, err := d.BaseInfo(c, mid)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- ctx.Convey("r should not be nil", func(ctx convey.C) {
- ctx.So(r, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoSetBase(t *testing.T) {
- var (
- c = context.Background()
- base = &model.BaseInfo{
- Mid: 0,
- }
- )
- convey.Convey("SetBase", t, func(ctx convey.C) {
- err := d.SetBase(c, base)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoSetSign(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(0)
- sign = "test"
- )
- convey.Convey("SetSign", t, func(ctx convey.C) {
- err := d.SetSign(c, mid, sign)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoSetName(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(0)
- name = "test"
- )
- convey.Convey("SetName", t, func(ctx convey.C) {
- err := d.SetName(c, mid, name)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoSetRank(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(0)
- rank = int64(100)
- )
- convey.Convey("SetRank", t, func(ctx convey.C) {
- err := d.SetRank(c, mid, rank)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoSetSex(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(0)
- sex = int64(1)
- )
- convey.Convey("SetSex", t, func(ctx convey.C) {
- err := d.SetSex(c, mid, sex)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoSetBirthday(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(0)
- birthday = time.Time(946656000)
- )
- convey.Convey("SetBirthday", t, func(ctx convey.C) {
- err := d.SetBirthday(c, mid, birthday)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoSetFace(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(0)
- face = "test"
- )
- convey.Convey("SetFace", t, func(ctx convey.C) {
- err := d.SetFace(c, mid, face)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoExpDB(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(0)
- )
- convey.Convey("ExpDB", t, func(ctx convey.C) {
- count, err := d.ExpDB(c, mid)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- ctx.Convey("count should not be nil", func(ctx convey.C) {
- ctx.So(count, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoSetExp(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(0)
- count = int64(10)
- )
- convey.Convey("SetExp", t, func(ctx convey.C) {
- affect, err := d.SetExp(c, mid, count)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- ctx.Convey("affect should not be nil", func(ctx convey.C) {
- ctx.So(affect, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoUpdateExp(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(0)
- delta = int64(6)
- )
- convey.Convey("UpdateExp", t, func(ctx convey.C) {
- affect, err := d.UpdateExp(c, mid, delta)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- ctx.Convey("affect should not be nil", func(ctx convey.C) {
- ctx.So(affect, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoUserAttrDB(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(0)
- attr uint
- )
- convey.Convey("UserAttrDB", t, func(ctx convey.C) {
- hasAttr, err := d.UserAttrDB(c, mid, attr)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- ctx.Convey("hasAttr should not be nil", func(ctx convey.C) {
- ctx.So(hasAttr, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoSetUserAttr(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(0)
- attr uint
- )
- convey.Convey("SetUserAttr", t, func(ctx convey.C) {
- err := d.SetUserAttr(c, mid, attr)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoOfficials(t *testing.T) {
- var (
- c = context.Background()
- )
- convey.Convey("Officials", t, func(ctx convey.C) {
- om, err := d.Officials(c)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- ctx.Convey("om should not be nil", func(ctx convey.C) {
- ctx.So(om, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoOfficial(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(1)
- )
- convey.Convey("Official", t, func(ctx convey.C) {
- p1, p2 := d.Official(c, mid)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(p2, convey.ShouldBeNil)
- })
- ctx.Convey("p1 should not be nil", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoMoralDB(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(4780461)
- )
- convey.Convey("MoralDB", t, func(ctx convey.C) {
- moral, err := d.MoralDB(c, mid)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- ctx.Convey("moral should not be nil", func(ctx convey.C) {
- ctx.So(moral, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoTxMoralDB(t *testing.T) {
- var (
- c = context.Background()
- tx, _ = d.db.Begin(c)
- mid = int64(8)
- )
- defer tx.Commit()
- convey.Convey("TxMoralDB", t, func(ctx convey.C) {
- moral, err := d.TxMoralDB(tx, mid)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- ctx.Convey("moral should not be nil", func(ctx convey.C) {
- ctx.So(moral, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoTxUpdateMoral(t *testing.T) {
- var (
- c = context.Background()
- tx, _ = d.db.Begin(c)
- mid = int64(0)
- moral = int64(0)
- added = int64(0)
- deducted = int64(0)
- )
- defer tx.Commit()
- convey.Convey("TxUpdateMoral", t, func(ctx convey.C) {
- err := d.TxUpdateMoral(tx, mid, moral, added, deducted)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoTxUpdateMoralRecoverDate(t *testing.T) {
- var (
- c = context.Background()
- tx, _ = d.db.Begin(c)
- mid = int64(0)
- recoverDate = time.Time(946656000)
- )
- defer tx.Commit()
- convey.Convey("TxUpdateMoralRecoverDate", t, func(ctx convey.C) {
- err := d.TxUpdateMoralRecoverDate(tx, mid, recoverDate)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoTxInitMoral(t *testing.T) {
- var (
- c = context.Background()
- tx, _ = d.db.Begin(c)
- mid = int64(10)
- moral = int64(0)
- added = int64(0)
- deducted = int64(0)
- lastRecoverDate = time.Time(946656000)
- )
- defer tx.Commit()
- convey.Convey("TxInitMoral", t, func(ctx convey.C) {
- err := d.TxInitMoral(tx, mid, moral, added, deducted, lastRecoverDate)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoSetOfficialDoc(t *testing.T) {
- var (
- c = context.Background()
- od = &model.OfficialDoc{
- Mid: 4780461,
- }
- )
- convey.Convey("SetOfficialDoc", t, func(ctx convey.C) {
- err := d.SetOfficialDoc(c, od)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoOfficialDoc(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(4780461)
- )
- convey.Convey("OfficialDoc", t, func(ctx convey.C) {
- p1, p2 := d.OfficialDoc(c, mid)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(p2, convey.ShouldBeNil)
- })
- ctx.Convey("p1 should not be nil", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoRealnameInfo(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(46333)
- )
- convey.Convey("TestDaoRealnameInfo", t, func(ctx convey.C) {
- info, err := d.RealnameInfo(c, mid)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- ctx.Convey("info should not be nil", func(ctx convey.C) {
- t.Logf("info:%+v", info)
- ctx.So(info, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoRealnameInfoByCard(t *testing.T) {
- var (
- c = context.Background()
- cardMD5 = "0088bdb8af58d25c1d9864e568a3cfb8"
- )
- convey.Convey("TestDaoRealnameInfoByCard", t, func(ctx convey.C) {
- info, err := d.RealnameInfoByCard(c, cardMD5)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- ctx.Convey("info should not be nil", func(ctx convey.C) {
- t.Logf("info:%+v", info)
- ctx.So(info, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoRealnameApply(t *testing.T) {
- var (
- c = context.Background()
- mid = int64(4780461)
- )
- convey.Convey("RealnameApply", t, func(ctx convey.C) {
- apply, err := d.RealnameApply(c, mid)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- ctx.Convey("apply should not be nil", func(ctx convey.C) {
- ctx.So(apply, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoInsertRealnameApply(t *testing.T) {
- var (
- c = context.Background()
- data = &model.RealnameApply{
- MID: 4780461,
- }
- )
- convey.Convey("InsertRealnameApply", t, func(ctx convey.C) {
- err := d.InsertRealnameApply(c, data)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoInsertRealnameApplyImg(t *testing.T) {
- var (
- c = context.Background()
- data = &model.RealnameApplyImage{
- ID: 1,
- IMGData: "1234",
- }
- )
- convey.Convey("InsertRealnameApplyImg", t, func(ctx convey.C) {
- id, err := d.InsertRealnameApplyImg(c, data)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- ctx.Convey("id should not be nil", func(ctx convey.C) {
- ctx.So(id, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoRealnameApplyIMG(t *testing.T) {
- var (
- c = context.Background()
- id = int(1)
- )
- convey.Convey("RealnameApplyIMG", t, func(ctx convey.C) {
- img, err := d.RealnameApplyIMG(c, id)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- ctx.Convey("img should not be nil", func(ctx convey.C) {
- ctx.So(img, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoInsertOldRealnameApply(t *testing.T) {
- var (
- c = context.Background()
- data = &model.RealnameApply{
- ID: 1,
- }
- )
- convey.Convey("InsertOldRealnameApply", t, func(ctx convey.C) {
- id, err := d.InsertOldRealnameApply(c, data)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- ctx.Convey("id should not be nil", func(ctx convey.C) {
- ctx.So(id, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoInsertOldRealnameApplyImg(t *testing.T) {
- var (
- c = context.Background()
- data = &model.RealnameApplyImage{
- ID: 1,
- IMGData: "1234",
- }
- )
- convey.Convey("InsertOldRealnameApplyImg", t, func(ctx convey.C) {
- id, err := d.InsertOldRealnameApplyImg(c, data)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- ctx.Convey("id should not be nil", func(ctx convey.C) {
- ctx.So(id, convey.ShouldNotBeNil)
- })
- })
- }
|