123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- package dao
- import (
- "context"
- "fmt"
- "testing"
- "time"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestDaoAddGoods(t *testing.T) {
- convey.Convey("AddGoods", t, func(ctx convey.C) {
- var (
- c = context.Background()
- fields = "ex_product_id, ex_resource_id, goods_type, is_display, discount"
- values = fmt.Sprintf("('%s', 1, 1, 1, 100)", time.Now().Format("2006-01-02 15:04:05"))
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- p1, err := d.AddGoods(c, fields, values)
- ctx.Convey("Then err should be nil.p1 should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoUpdateGoods(t *testing.T) {
- convey.Convey("UpdateGoods", t, func(ctx convey.C) {
- var (
- c = context.Background()
- set = "is_display=1"
- where = "is_deleted=0"
- IDs = []int64{1}
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- p1, err := d.UpdateGoods(c, set, where, IDs)
- ctx.Convey("Then err should be nil.p1 should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(p1, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoGoodsList(t *testing.T) {
- convey.Convey("GoodsList", t, func(ctx convey.C) {
- var (
- c = context.Background()
- where = "is_deleted=0"
- from = int(0)
- limit = int(0)
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- res, err := d.GoodsList(c, where, from, limit)
- 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 TestDaoGoodsCount(t *testing.T) {
- convey.Convey("GoodsCount", t, func(ctx convey.C) {
- var (
- c = context.Background()
- where = "is_deleted=0"
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- total, err := d.GoodsCount(c, where)
- ctx.Convey("Then err should be nil.total should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(total, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoOrderCount(t *testing.T) {
- convey.Convey("OrderCount", t, func(ctx convey.C) {
- var (
- c = context.Background()
- where = "is_deleted=0"
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- total, err := d.OrderCount(c, where)
- ctx.Convey("Then err should be nil.total should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(total, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoOrderList(t *testing.T) {
- convey.Convey("OrderList", t, func(ctx convey.C) {
- var (
- c = context.Background()
- where = "is_deleted=0"
- from = int(0)
- limit = int(0)
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- res, err := d.OrderList(c, where, from, limit)
- 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)
- })
- })
- })
- }
|