123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- package dao
- import (
- "context"
- "testing"
- "time"
- "go-common/app/service/main/vip/model"
- xtime "go-common/library/time"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestDaoVipInfo(t *testing.T) {
- var (
- c = context.TODO()
- mid = int64(0)
- )
- convey.Convey("VipInfo", t, func(ctx convey.C) {
- r, err := d.VipInfo(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 TestDaoUpdateVipTypeAndStatus(t *testing.T) {
- var (
- c = context.TODO()
- mid = int64(0)
- vipStatus = int32(0)
- vipType = int32(0)
- )
- convey.Convey("UpdateVipTypeAndStatus", t, func(ctx convey.C) {
- ret, err := d.UpdateVipTypeAndStatus(c, mid, vipStatus, vipType)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- ctx.Convey("ret should not be nil", func(ctx convey.C) {
- ctx.So(ret, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoSelChangeHistoryCount(t *testing.T) {
- var (
- c = context.TODO()
- arg = &model.ArgChangeHistory{}
- )
- convey.Convey("SelChangeHistoryCount", t, func(ctx convey.C) {
- count, err := d.SelChangeHistoryCount(c, arg)
- 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 TestDaoSelChangeHistory(t *testing.T) {
- var (
- c = context.TODO()
- arg = &model.ArgChangeHistory{}
- )
- convey.Convey("SelChangeHistory", t, func(ctx convey.C) {
- _, err := d.SelChangeHistory(c, arg)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoTxUpdateChannelID(t *testing.T) {
- var (
- c = context.TODO()
- mid = int64(0)
- payChannelID = int32(0)
- ver = int64(0)
- oldVer = int64(0)
- )
- convey.Convey("TxUpdateChannelID", t, func(ctx convey.C) {
- tx, err := d.StartTx(c)
- ctx.Convey("Tx Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- defer tx.Commit()
- err = d.TxUpdateChannelID(tx, mid, payChannelID, ver, oldVer)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoTxDupUserDiscount(t *testing.T) {
- var (
- c = context.TODO()
- mid = int64(0)
- discountID = int64(0)
- orderNo = ""
- status = int8(0)
- )
- convey.Convey("TxDupUserDiscount", t, func(ctx convey.C) {
- tx, err := d.StartTx(c)
- ctx.Convey("Tx Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- defer tx.Commit()
- err = d.TxDupUserDiscount(tx, mid, discountID, orderNo, status)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoUpdatePayType(t *testing.T) {
- var (
- c = context.TODO()
- mid = int64(0)
- payType = int8(0)
- ver = int64(0)
- oldVer = int64(0)
- )
- convey.Convey("UpdatePayType", t, func(ctx convey.C) {
- tx, err := d.StartTx(c)
- ctx.Convey("Tx Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- defer tx.Commit()
- a, err := d.UpdatePayType(tx, mid, payType, ver, oldVer)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- ctx.Convey("a should not be nil", func(ctx convey.C) {
- ctx.So(a, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoSelVipChangeHistory(t *testing.T) {
- var (
- c = context.TODO()
- relationID = ""
- )
- convey.Convey("SelVipChangeHistory", t, func(ctx convey.C) {
- r, err := d.SelVipChangeHistory(c, relationID)
- 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 TestDaoInsertVipChangeHistory(t *testing.T) {
- var (
- c = context.TODO()
- r = &model.VipChangeHistory{}
- )
- convey.Convey("InsertVipChangeHistory", t, func(ctx convey.C) {
- tx, err := d.StartTx(c)
- ctx.Convey("Tx Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- defer tx.Commit()
- id, err := d.InsertVipChangeHistory(tx, r)
- 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 TestDaoTxSelVipUserInfo(t *testing.T) {
- var (
- c = context.TODO()
- mid = int64(20606508)
- )
- convey.Convey("TxSelVipUserInfo", t, func(ctx convey.C) {
- tx, err := d.StartTx(c)
- ctx.Convey("Tx Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- defer tx.Commit()
- r, err := d.TxSelVipUserInfo(tx, 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 TestDaoTxAddIosVipUserInfo(t *testing.T) {
- var (
- c = context.TODO()
- r = &model.VipInfoDB{
- Mid: time.Now().Unix(),
- VipType: 1,
- VipPayType: 1,
- VipStatus: 0,
- VipStartTime: xtime.Time(time.Now().Unix()),
- VipOverdueTime: xtime.Time(time.Now().Unix()),
- AnnualVipOverdueTime: xtime.Time(time.Now().Unix()),
- VipRecentTime: xtime.Time(time.Now().Unix()),
- }
- )
- convey.Convey("TxAddIosVipUserInfo", t, func(ctx convey.C) {
- tx, err := d.StartTx(c)
- ctx.Convey("Tx Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- eff, err := d.TxAddIosVipUserInfo(tx, r)
- err = tx.Commit()
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- ctx.Convey("eff should not be nil", func(ctx convey.C) {
- ctx.So(eff, convey.ShouldNotBeNil)
- })
- err = d.InsertVipUserInfo(tx, r)
- ctx.Convey("Error should not be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoTxUpdateIosUserInfo(t *testing.T) {
- var (
- c = context.TODO()
- iosTime = xtime.Time(time.Now().Unix())
- mid = int64(0)
- )
- convey.Convey("TxUpdateIosUserInfo", t, func(ctx convey.C) {
- tx, err := d.StartTx(c)
- ctx.Convey("Tx Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- defer tx.Commit()
- eff, err := d.TxUpdateIosUserInfo(tx, iosTime, mid)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- ctx.Convey("eff should not be nil", func(ctx convey.C) {
- ctx.So(eff, convey.ShouldNotBeNil)
- })
- })
- }
- func TestDaoTxUpdateIosRenewUserInfo(t *testing.T) {
- var (
- c = context.TODO()
- paychannelID = int64(1)
- ver = int64(1)
- oldVer = int64(123)
- mid = int64(20606508)
- payType = int8(1)
- )
- convey.Convey("TxUpdateIosRenewUserInfo", t, func(ctx convey.C) {
- tx, err := d.StartTx(c)
- ctx.Convey("Tx Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- defer tx.Commit()
- err = d.TxUpdateIosRenewUserInfo(tx, paychannelID, ver, oldVer, mid, payType)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoUpdateVipUserInfo(t *testing.T) {
- var (
- c = context.TODO()
- r = &model.VipInfoDB{
- Mid: 206065080,
- VipType: 1,
- VipPayType: 1,
- VipStatus: 0,
- VipStartTime: xtime.Time(time.Now().Unix()),
- VipOverdueTime: xtime.Time(time.Now().Unix()),
- AnnualVipOverdueTime: xtime.Time(time.Now().Unix()),
- VipRecentTime: xtime.Time(time.Now().Unix()),
- }
- ver = int64(0)
- )
- convey.Convey("UpdateVipUserInfo", t, func(ctx convey.C) {
- tx, err := d.StartTx(c)
- ctx.Convey("Tx Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- defer tx.Commit()
- a, err := d.UpdateVipUserInfo(tx, r, ver)
- ctx.Convey("Error should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- ctx.Convey("a should not be nil", func(ctx convey.C) {
- ctx.So(a, convey.ShouldNotBeNil)
- })
- })
- }
|