123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- package dao
- import (
- "context"
- "go-common/app/service/main/vip/model"
- "testing"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestDaoGetWelfareList(t *testing.T) {
- convey.Convey("GetWelfareList", t, func(ctx convey.C) {
- var (
- c = context.Background()
- req = &model.ArgWelfareList{}
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- _, err := d.GetWelfareList(c, req)
- ctx.Convey("Then err should be nil", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoCountWelfare(t *testing.T) {
- convey.Convey("CountWelfare", t, func(ctx convey.C) {
- var (
- c = context.Background()
- req = &model.ArgWelfareList{}
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- count, err := d.CountWelfare(c, req)
- 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 TestDaoGetRecommendWelfare(t *testing.T) {
- convey.Convey("GetRecommendWelfare", t, func(ctx convey.C) {
- var (
- c = context.Background()
- req = &model.ArgWelfareList{}
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- _, err := d.GetRecommendWelfare(c, req)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoCountRecommendWelfare(t *testing.T) {
- convey.Convey("CountRecommendWelfare", t, func(ctx convey.C) {
- var (
- c = context.Background()
- req = &model.ArgWelfareList{}
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- count, err := d.CountRecommendWelfare(c, req)
- 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 TestDaoGetWelfareTypeList(t *testing.T) {
- convey.Convey("GetWelfareTypeList", t, func(ctx convey.C) {
- var (
- c = context.Background()
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- res, err := d.GetWelfareTypeList(c)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoGetWelfareInfo(t *testing.T) {
- convey.Convey("GetWelfareInfo", t, func(ctx convey.C) {
- var (
- c = context.Background()
- id = int64(0)
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- _, err := d.GetWelfareInfo(c, id)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoGetWelfareBatch(t *testing.T) {
- convey.Convey("GetWelfareBatch", t, func(ctx convey.C) {
- var (
- c = context.Background()
- wid = int64(0)
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- _, err := d.GetWelfareBatch(c, wid)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoGetReceivedCode(t *testing.T) {
- convey.Convey("GetReceivedCode", t, func(ctx convey.C) {
- var (
- c = context.Background()
- wid = int64(0)
- mid = int64(0)
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- _, err := d.GetReceivedCode(c, wid, mid)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoUpdateWelfareCodeUser(t *testing.T) {
- convey.Convey("UpdateWelfareCodeUser", t, func(ctx convey.C) {
- var (
- c = context.Background()
- id = int(0)
- mid = int64(0)
- )
- tx, _ := d.StartTx(c)
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- res, err := d.UpdateWelfareCodeUser(c, tx, id, mid)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoUpdateWelfareBatch(t *testing.T) {
- convey.Convey("UpdateWelfareBatch", t, func(ctx convey.C) {
- var (
- c = context.Background()
- bid = int(0)
- )
- tx, err := d.StartTx(c)
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- err = d.UpdateWelfareBatch(c, tx, bid)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoGetWelfareCodeUnReceived(t *testing.T) {
- convey.Convey("GetWelfareCodeUnReceived", t, func(ctx convey.C) {
- var (
- c = context.Background()
- wid = int64(0)
- bids = []string{}
- )
- bids = append(bids, "1")
- bids = append(bids, "2")
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- _, err := d.GetWelfareCodeUnReceived(c, wid, bids)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoGetMyWelfare(t *testing.T) {
- convey.Convey("GetMyWelfare", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mid = int64(0)
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- _, err := d.GetMyWelfare(c, mid)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoAddReceiveRedirectWelfare(t *testing.T) {
- convey.Convey("AddReceiveRedirectWelfare", t, func(ctx convey.C) {
- var (
- c = context.Background()
- wid = int64(0)
- mid = int64(0)
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- err := d.AddReceiveRedirectWelfare(c, wid, mid)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoCountReceiveRedirectWelfare(t *testing.T) {
- convey.Convey("CountReceiveRedirectWelfare", t, func(ctx convey.C) {
- var (
- c = context.Background()
- wid = int64(0)
- mid = int64(0)
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- count, err := d.CountReceiveRedirectWelfare(c, wid, 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 TestDaoInsertReceiveRecord(t *testing.T) {
- convey.Convey("InsertReceiveRecord", t, func(ctx convey.C) {
- var (
- c = context.Background()
- wid = int64(0)
- mid = int64(0)
- monthYear = int64(0)
- )
- tx, err := d.StartTx(c)
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- err = d.InsertReceiveRecord(c, tx, wid, mid, monthYear)
- ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
|