123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320 |
- package upcrm
- import (
- "testing"
- "time"
- "go-common/app/admin/main/up/model/signmodel"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestUpcrmInsertSignUp(t *testing.T) {
- convey.Convey("InsertSignUp", t, func(ctx convey.C) {
- var (
- db = d.crmdb
- up = &signmodel.SignUp{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- affectedRow, err := d.InsertSignUp(db, up)
- d.crmdb.Delete(up)
- ctx.Convey("Then err should be nil.affectedRow should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(affectedRow, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpcrmInsertPayInfo(t *testing.T) {
- convey.Convey("InsertPayInfo", t, func(ctx convey.C) {
- var (
- db = d.crmdb
- info = &signmodel.SignPay{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- affectedRow, err := d.InsertPayInfo(db, info)
- d.crmdb.Delete(info)
- ctx.Convey("Then err should be nil.affectedRow should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(affectedRow, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpcrmInsertTaskInfo(t *testing.T) {
- convey.Convey("InsertTaskInfo", t, func(ctx convey.C) {
- var (
- db = d.crmdb
- info = &signmodel.SignTask{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- affectedRow, err := d.InsertTaskInfo(db, info)
- d.crmdb.Delete(info)
- ctx.Convey("Then err should be nil.affectedRow should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(affectedRow, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpcrmInsertContractInfo(t *testing.T) {
- convey.Convey("InsertContractInfo", t, func(ctx convey.C) {
- var (
- db = d.crmdb
- info = &signmodel.SignContract{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- affectedRow, err := d.InsertContractInfo(db, info)
- d.crmdb.Delete(info)
- ctx.Convey("Then err should be nil.affectedRow should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(affectedRow, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpcrmDelPayInfo(t *testing.T) {
- convey.Convey("DelPayInfo", t, func(ctx convey.C) {
- var (
- db = d.crmdb
- ids = []int64{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- affectedRow, err := d.DelPayInfo(db, ids)
- ctx.Convey("Then err should be nil.affectedRow should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(affectedRow, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpcrmDelTaskInfo(t *testing.T) {
- convey.Convey("DelTaskInfo", t, func(ctx convey.C) {
- var (
- db = d.crmdb
- ids = []int64{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- affectedRow, err := d.DelTaskInfo(db, ids)
- ctx.Convey("Then err should be nil.affectedRow should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(affectedRow, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpcrmDelSignContract(t *testing.T) {
- convey.Convey("DelSignContract", t, func(ctx convey.C) {
- var (
- db = d.crmdb
- ids = []int64{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- affectedRow, err := d.DelSignContract(db, ids)
- ctx.Convey("Then err should be nil.affectedRow should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(affectedRow, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpcrmSignUpID(t *testing.T) {
- convey.Convey("SignUpID", t, func(ctx convey.C) {
- var (
- sigID = int64(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- su, msp, mst, msc, err := d.SignUpID(sigID)
- ctx.Convey("Then err should be nil.su,msp,mst,msc should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(msc, convey.ShouldBeNil)
- ctx.So(mst, convey.ShouldBeNil)
- ctx.So(msp, convey.ShouldBeNil)
- ctx.So(su, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestUpcrmGetSignIDByCondition(t *testing.T) {
- convey.Convey("GetSignIDByCondition", t, func(ctx convey.C) {
- var (
- arg = &signmodel.SignQueryArg{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- signIDs, err := d.GetSignIDByCondition(arg)
- ctx.Convey("Then err should be nil.signIDs should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(signIDs, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestUpcrmGetSignUpByID(t *testing.T) {
- convey.Convey("GetSignUpByID", t, func(ctx convey.C) {
- var (
- signID = []uint32{}
- order = ""
- offset = int(0)
- limit = int(0)
- query = interface{}(0)
- args = interface{}(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- result, err := d.GetSignUpByID(signID, order, offset, limit, query, args)
- ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(result, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpcrmGetSignUpCount(t *testing.T) {
- convey.Convey("GetSignUpCount", t, func(ctx convey.C) {
- var (
- query = ""
- args = interface{}(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- count := d.GetSignUpCount(query, args)
- ctx.Convey("Then count should not be nil.", func(ctx convey.C) {
- ctx.So(count, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpcrmGetTask(t *testing.T) {
- convey.Convey("GetTask", t, func(ctx convey.C) {
- var (
- signID = []uint32{}
- state = int(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- result, err := d.GetTask(signID, state)
- ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(result, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpcrmGetPay(t *testing.T) {
- convey.Convey("GetPay", t, func(ctx convey.C) {
- var (
- signID = []uint32{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- result, err := d.GetPay(signID)
- ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(result, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpcrmGetContract(t *testing.T) {
- convey.Convey("GetContract", t, func(ctx convey.C) {
- var (
- signID = []uint32{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- result, err := d.GetContract(signID)
- ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(result, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpcrmPayComplete(t *testing.T) {
- convey.Convey("PayComplete", t, func(ctx convey.C) {
- var (
- ids = []int64{1, 2}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- affectedRow, err := d.PayComplete(ids)
- ctx.Convey("Then err should be nil.affectedRow should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(affectedRow, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpcrmGetDueSignUp(t *testing.T) {
- convey.Convey("GetDueSignUp", t, func(ctx convey.C) {
- var (
- now = time.Now()
- expireAfterDays = int(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- result, err := d.GetDueSignUp(now, expireAfterDays)
- ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(result, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpcrmGetDuePay(t *testing.T) {
- convey.Convey("GetDuePay", t, func(ctx convey.C) {
- var (
- now = time.Now()
- expireAfterDays = int(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- result, err := d.GetDuePay(now, expireAfterDays)
- ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(result, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestUpcrmUpdateEmailState(t *testing.T) {
- convey.Convey("UpdateEmailState", t, func(ctx convey.C) {
- var (
- table = "sign_up"
- ids = []int64{}
- state = int8(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- affectedRow, err := d.UpdateEmailState(table, ids, state)
- ctx.Convey("Then err should be nil.affectedRow should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(affectedRow, convey.ShouldEqual, 0)
- })
- })
- })
- }
- func TestUpcrmCheckUpHasValidContract(t *testing.T) {
- convey.Convey("CheckUpHasValidContract", t, func(ctx convey.C) {
- var (
- mid = int64(0)
- date = time.Now()
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- exist, err := d.CheckUpHasValidContract(mid, date)
- ctx.Convey("Then err should be nil.exist should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(exist, convey.ShouldNotBeNil)
- })
- })
- })
- }
|