123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535 |
- package up
- import (
- "context"
- "fmt"
- "testing"
- "go-common/app/admin/main/mcn/model"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestUpTxAddMCNRenewal(t *testing.T) {
- convey.Convey("TxAddMCNRenewal", t, func(ctx convey.C) {
- var (
- tx, err = d.BeginTran(context.Background())
- arg = &model.MCNSign{MCNMID: 1}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- lastID, err := d.TxAddMCNRenewal(tx, arg)
- defer tx.Rollback()
- ctx.Convey("Then err should be nil. lastID should greater than zero.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(lastID, convey.ShouldBeGreaterThan, 0)
- })
- })
- })
- }
- func TestUpTxAddMCNPays(t *testing.T) {
- convey.Convey("TxAddMCNPays", t, func(ctx convey.C) {
- var (
- tx, err = d.BeginTran(context.Background())
- lastID = int64(1)
- mcnMID = int64(1)
- payInfo1, payInfo2 = &model.SignPayReq{}, &model.SignPayReq{}
- arg = []*model.SignPayReq{}
- )
- payInfo1.DueDate = "2018-10-25"
- payInfo1.PayValue = 10000
- arg = append(arg, payInfo1)
- payInfo2.DueDate = "2018-11-25"
- payInfo2.PayValue = 20000
- arg = append(arg, payInfo2)
- ctx.So(err, convey.ShouldBeNil)
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.TxAddMCNPays(tx, lastID, mcnMID, arg)
- defer tx.Rollback()
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestUpTxAddMCNUPs(t *testing.T) {
- convey.Convey("TxAddMCNUPs", t, func(ctx convey.C) {
- var (
- tx, _ = d.BeginTran(context.Background())
- lastID = int64(1)
- mcnMID = int64(1)
- arg []*model.MCNUP
- up = &model.MCNUP{
- SignID: 1,
- MCNMID: 1,
- UPMID: 1,
- BeginDate: 0,
- EndDate: 0,
- ContractLink: "http://www.baidu.com",
- UPAuthLink: "http://www.baidu.com",
- State: 1,
- StateChangeTime: 0,
- Permission: 1,
- }
- )
- arg = append(arg, up)
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.TxAddMCNUPs(tx, lastID, mcnMID, arg)
- defer func() {
- tx.Rollback()
- }()
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestUpUpMCNState(t *testing.T) {
- convey.Convey("UpMCNState", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.MCNStateEditReq{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rows, err := d.UpMCNState(c, arg)
- 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 TestUpUpMCNPay(t *testing.T) {
- convey.Convey("UpMCNPay", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.MCNPayEditReq{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rows, err := d.UpMCNPay(c, arg)
- 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 TestUpUpMCNPayState(t *testing.T) {
- convey.Convey("UpMCNPayState", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.MCNPayStateEditReq{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rows, err := d.UpMCNPayState(c, arg)
- 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 TestUpMCNList(t *testing.T) {
- convey.Convey("MCNList", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.MCNListReq{}
- )
- arg.State = -1
- arg.Order = "s.mtime"
- arg.Sort = "DESC"
- arg.Page = 1
- arg.Size = 10
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, ids, mids, err := d.MCNList(c, arg)
- ctx.Convey("Then err should be nil.res,ids should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(ids, convey.ShouldNotBeNil)
- ctx.So(mids, convey.ShouldNotBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpbuildMCNListSQL(t *testing.T) {
- convey.Convey("buildMCNListSQL", t, func(ctx convey.C) {
- var (
- SQLType = ""
- arg = &model.MCNListReq{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- sql, values := d.buildMCNListSQL(SQLType, arg)
- ctx.Convey("Then sql,values should not be nil.", func(ctx convey.C) {
- ctx.So(values, convey.ShouldNotBeNil)
- ctx.So(sql, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpcheckSort(t *testing.T) {
- convey.Convey("checkSort", t, func(ctx convey.C) {
- var (
- arg = ""
- orderSign bool
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- p1 := checkSort(arg, orderSign)
- ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpMcnListTotal(t *testing.T) {
- convey.Convey("McnListTotal", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.MCNListReq{
- State: -1,
- }
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- count, err := d.MCNListTotal(c, arg)
- 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 TestUpMCNPayInfos(t *testing.T) {
- convey.Convey("MCNPayInfos", t, func(ctx convey.C) {
- var (
- c = context.Background()
- ids = []int64{1, 2}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.MCNPayInfos(c, ids)
- 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 TestUpTxMCNRenewalUPs(t *testing.T) {
- convey.Convey("TxMCNRenewalUPs", t, func(ctx convey.C) {
- var (
- tx, _ = d.BeginTran(context.Background())
- signID = int64(1)
- mcnID = int64(1)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- ups, err := d.TxMCNRenewalUPs(tx, signID, mcnID)
- defer func() {
- if err != nil {
- tx.Rollback()
- } else {
- tx.Commit()
- }
- }()
- ctx.Convey("Then err should be nil.ups should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- if len(ups) == 0 {
- ctx.So(ups, convey.ShouldBeEmpty)
- } else {
- ctx.So(ups, convey.ShouldNotBeNil)
- }
- })
- })
- })
- }
- func TestUpMCNInfo(t *testing.T) {
- convey.Convey("MCNInfo", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.MCNInfoReq{ID: 1}
- )
- arg.MCNMID = 1
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- m, err := d.MCNInfo(c, arg)
- ctx.Convey("Then err should be nil.m should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- if m == nil {
- ctx.So(m, convey.ShouldBeNil)
- } else {
- ctx.So(m, convey.ShouldNotBeNil)
- }
- })
- })
- })
- }
- func TestUpMCNUPList(t *testing.T) {
- convey.Convey("MCNUPList", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.MCNUPListReq{}
- )
- arg.DataType = 1
- arg.State = -1
- arg.UpType = -1
- arg.Order = "u.mtime"
- arg.Sort = "DESC"
- arg.Page = 1
- arg.Size = 10
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.MCNUPList(c, arg)
- 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.ShouldBeEmpty)
- })
- })
- })
- }
- func TestUpMCNUPListTotal(t *testing.T) {
- convey.Convey("MCNUPListTotal", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.MCNUPListReq{}
- )
- arg.DataType = 1
- arg.State = -1
- arg.UpType = -1
- arg.Order = "u.mtime"
- arg.Sort = "DESC"
- arg.Page = 1
- arg.Size = 10
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- count, err := d.MCNUPListTotal(c, arg)
- 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 TestUpbuildMCNUPListSQL(t *testing.T) {
- convey.Convey("buildMCNUPListSQL", t, func(ctx convey.C) {
- var (
- SQLType = ""
- arg = &model.MCNUPListReq{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- sql, values := d.buildMCNUPListSQL(SQLType, arg)
- ctx.Convey("Then sql,values should not be nil.", func(ctx convey.C) {
- ctx.So(values, convey.ShouldNotBeNil)
- ctx.So(sql, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpUpMCNUPState(t *testing.T) {
- convey.Convey("UpMCNUPState", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.MCNUPStateEditReq{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rows, err := d.UpMCNUPState(c, arg)
- 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 TestUpMcnSignByMCNMID(t *testing.T) {
- convey.Convey("McnSignByMCNMID", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mcnID = int64(1)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- row, err := d.McnSignByMCNMID(c, mcnID)
- ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(row, convey.ShouldNotBeEmpty)
- })
- })
- })
- }
- func TestUpMCNCheatList(t *testing.T) {
- convey.Convey("TestUpMCNCheatList", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.MCNCheatListReq{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rows, mids, err := d.MCNCheatList(c, arg)
- ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
- for k, r := range rows {
- fmt.Printf("%d:%+v \n", k, r)
- }
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(rows, convey.ShouldNotBeNil)
- ctx.So(mids, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpMCNCheatListTotal(t *testing.T) {
- convey.Convey("TestUpMCNCheatListTotal", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.MCNCheatListReq{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- count, err := d.MCNCheatListTotal(c, arg)
- ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
- fmt.Printf("count:%d \n", count)
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(count, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpMCNCheatUPList(t *testing.T) {
- convey.Convey("TestUpMCNCheatUPList", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.MCNCheatUPListReq{UPMID: 1}
- )
- arg.Page = 1
- arg.Size = 10
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rows, err := d.MCNCheatUPList(c, arg)
- ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
- for k, r := range rows {
- fmt.Printf("%d:%+v \n", k, r)
- }
- ctx.So(err, convey.ShouldBeNil)
- if len(rows) == 0 {
- ctx.So(rows, convey.ShouldBeEmpty)
- } else {
- ctx.So(rows, convey.ShouldNotBeNil)
- }
- })
- })
- })
- }
- func TestUpMCNCheatUPListTotal(t *testing.T) {
- convey.Convey("TestUpMCNCheatUPListTotal", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.MCNCheatUPListReq{UPMID: 1}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- count, err := d.MCNCheatUPListTotal(c, arg)
- ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
- fmt.Printf("count:%d \n", count)
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(count, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpMCNImportUPInfo(t *testing.T) {
- convey.Convey("TestUpMCNImportUPInfo", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.MCNImportUPInfoReq{UPMID: 1}
- )
- arg.SignID = 1
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- res, err := d.MCNImportUPInfo(c, arg)
- ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
- fmt.Printf("res:%+v \n", res)
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpUpMCNImportUPRewardSign(t *testing.T) {
- convey.Convey("TestUpUpMCNImportUPRewardSign", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.MCNImportUPRewardSignReq{UPMID: 1}
- )
- arg.SignID = 1
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- res, err := d.UpMCNImportUPRewardSign(c, arg)
- ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
- fmt.Printf("res:%+v \n", res)
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpUpMCNPermission(t *testing.T) {
- convey.Convey("UpMCNPermission", t, func(ctx convey.C) {
- var (
- c = context.Background()
- signID = int64(0)
- permission = uint32(0)
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- rows, err := d.UpMCNPermission(c, signID, permission)
- 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 TestUpMCNIncreaseList(t *testing.T) {
- convey.Convey("TestUpMCNIncreaseList", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.MCNIncreaseListReq{}
- )
- arg.SignID = 99
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- rows, err := d.MCNIncreaseList(c, arg)
- ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
- for k, r := range rows {
- fmt.Printf("%d:%+v \n", k, r)
- }
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(rows, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpMCNIncreaseListTotal(t *testing.T) {
- convey.Convey("TestUpMCNIncreaseListTotal", t, func(ctx convey.C) {
- var (
- c = context.Background()
- arg = &model.MCNIncreaseListReq{}
- )
- arg.SignID = 99
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- count, err := d.MCNIncreaseListTotal(c, arg)
- ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
- fmt.Printf("count:%d \n", count)
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(count, convey.ShouldNotBeNil)
- })
- })
- })
- }
|