123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372 |
- package pendant
- import (
- "strconv"
- "testing"
- "time"
- "go-common/app/service/main/usersuit/model"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestPendantPendantGroupInfo(t *testing.T) {
- convey.Convey("PendantGroupInfo", t, func(ctx convey.C) {
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.PendantGroupInfo(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 TestPendantGroupByID(t *testing.T) {
- convey.Convey("GroupByID", t, func(ctx convey.C) {
- var (
- gid = int64(4)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.GroupByID(c, gid)
- 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 TestPendantGIDRefPID(t *testing.T) {
- convey.Convey("GIDRefPID", t, func(ctx convey.C) {
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- gidMap, pidMap, err := d.GIDRefPID(c)
- ctx.Convey("Then err should be nil.gidMap,pidMap should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(pidMap, convey.ShouldNotBeNil)
- ctx.So(gidMap, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestPendantPendantList(t *testing.T) {
- convey.Convey("PendantList", t, func(ctx convey.C) {
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.PendantList(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 TestPendantPendants(t *testing.T) {
- convey.Convey("Pendants", t, func(ctx convey.C) {
- var (
- pids = []int64{4}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.Pendants(c, pids)
- 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 TestPendantPendantInfo(t *testing.T) {
- convey.Convey("PendantInfo", t, func(ctx convey.C) {
- var (
- pid = int64(4)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.PendantInfo(c, pid)
- 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 TestPendantPendantPrice(t *testing.T) {
- convey.Convey("PendantPrice", t, func(ctx convey.C) {
- var (
- pid = int64(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.PendantPrice(c, pid)
- 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 TestPendantgetOrderInfoSQL(t *testing.T) {
- convey.Convey("getOrderInfoSQL", t, func(ctx convey.C) {
- var (
- arg = &model.ArgOrderHistory{}
- tp = ""
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- sql, values := d.getOrderInfoSQL(c, arg, tp)
- ctx.Convey("Then sql,values should not be nil.", func(ctx convey.C) {
- ctx.So(values, convey.ShouldNotBeNil)
- ctx.So(sql, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestPendantOrderInfo(t *testing.T) {
- convey.Convey("OrderInfo", t, func(ctx convey.C) {
- var (
- arg = &model.ArgOrderHistory{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, count, err := d.OrderInfo(c, arg)
- ctx.Convey("Then err should be nil.res,count should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(count, convey.ShouldNotBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestPendantOrderInfoByID(t *testing.T) {
- convey.Convey("OrderInfoByID", t, func(ctx convey.C) {
- var (
- orderID = ""
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.OrderInfoByID(c, orderID)
- 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 TestPendantAddOrderInfo(t *testing.T) {
- convey.Convey("AddOrderInfo", t, func(ctx convey.C) {
- var (
- arg = &model.PendantOrderInfo{Mid: 650454, OrderID: strconv.FormatInt(time.Now().Unix(), 10)}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- id, err := d.AddOrderInfo(c, arg)
- ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(id, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestPendantTxAddOrderInfo(t *testing.T) {
- convey.Convey("TxAddOrderInfo", t, func(ctx convey.C) {
- var (
- arg = &model.PendantOrderInfo{Mid: 650454, OrderID: strconv.FormatInt(time.Now().UnixNano(), 10)}
- tx, _ = d.BeginTran(c)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- id, err := d.TxAddOrderInfo(c, arg, tx)
- ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(id, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestPendantUpdateOrderInfo(t *testing.T) {
- convey.Convey("UpdateOrderInfo", t, func(ctx convey.C) {
- var (
- arg = &model.PendantOrderInfo{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- id, err := d.UpdateOrderInfo(c, arg)
- ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(id, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestPendantTxUpdateOrderInfo(t *testing.T) {
- convey.Convey("TxUpdateOrderInfo", t, func(ctx convey.C) {
- var (
- arg = &model.PendantOrderInfo{}
- tx, _ = d.BeginTran(c)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- id, err := d.TxUpdateOrderInfo(c, arg, tx)
- ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(id, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestPendantPackageByMid(t *testing.T) {
- convey.Convey("PackageByMid", t, func(ctx convey.C) {
- var (
- mid = int64(650454)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.PackageByMid(c, 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 TestPendantPackageByID(t *testing.T) {
- convey.Convey("PackageByID", t, func(ctx convey.C) {
- var (
- mid = int64(650454)
- pid = int64(21)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.PackageByID(c, mid, pid)
- 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 TestPendantEquipByMid(t *testing.T) {
- convey.Convey("EquipByMid", t, func(ctx convey.C) {
- var (
- mid = int64(88888929)
- no = int64(44)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, noRow, err := d.EquipByMid(c, mid, no)
- ctx.Convey("Then err should be nil.res,noRow should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(noRow, convey.ShouldNotBeNil)
- ctx.So(res, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestPendantEquipByMids(t *testing.T) {
- convey.Convey("EquipByMids", t, func(ctx convey.C) {
- var (
- mids = []int64{650454}
- no = int64(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.EquipByMids(c, mids, no)
- 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 TestPendantAddEquip(t *testing.T) {
- convey.Convey("AddEquip", t, func(ctx convey.C) {
- var (
- arg = &model.PendantEquip{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- n, err := d.AddEquip(c, arg)
- ctx.Convey("Then err should be nil.n should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(n, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestPendantTxUpdatePackageInfo(t *testing.T) {
- convey.Convey("TxUpdatePackageInfo", t, func(ctx convey.C) {
- var (
- arg = &model.PendantPackage{Mid: 88888929, Pid: 2, Status: 1}
- tx, _ = d.BeginTran(c)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- n, err := d.TxUpdatePackageInfo(c, arg, tx)
- ctx.Convey("Then err should be nil.n should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(n, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestPendantCheckPackageExpire(t *testing.T) {
- convey.Convey("CheckPackageExpire", t, func(ctx convey.C) {
- var (
- mid = int64(650454)
- expires = int64(2147483647)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rows, err := d.CheckPackageExpire(c, mid, expires)
- 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 TestPendantBeginTran(t *testing.T) {
- convey.Convey("BeginTran", t, func(ctx convey.C) {
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.BeginTran(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 TestPendantTxAddPackage(t *testing.T) {
- convey.Convey("TxAddPackage", t, func(ctx convey.C) {
- var (
- arg = &model.PendantPackage{Mid: time.Now().Unix(), Pid: 4}
- tx, _ = d.BeginTran(c)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- id, err := d.TxAddPackage(c, arg, tx)
- ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(id, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestPendantTxAddHistory(t *testing.T) {
- convey.Convey("TxAddHistory", t, func(ctx convey.C) {
- var (
- arg = &model.PendantHistory{}
- tx, _ = d.BeginTran(c)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- id, err := d.TxAddHistory(c, arg, tx)
- ctx.Convey("Then err should be nil.id should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(id, convey.ShouldNotBeNil)
- })
- })
- })
- }
|