123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- package dao
- import (
- "context"
- "fmt"
- "testing"
- "time"
- "go-common/app/admin/main/vip/model"
- xtime "go-common/library/time"
- . "github.com/smartystreets/goconvey/convey"
- )
- func TestDaoAddVipPriceConfig(t *testing.T) {
- Convey("Test_AddVipPriceConfig", t, func() {
- v := &model.VipPriceConfig{
- Plat: 1,
- PdName: "ddd",
- PdID: "sss",
- SuitType: 1,
- Month: 1,
- SubType: 2,
- OPrice: 1,
- Selected: 1,
- Remark: "",
- Status: 0,
- Operator: "sss",
- OpID: 1,
- }
- err := d.AddVipPriceConfig(context.TODO(), v)
- So(err, ShouldBeNil)
- })
- Convey("Test_AddVipPriceConfig add build 200-300", t, func() {
- v := &model.VipPriceConfig{
- Plat: 10,
- PdName: "ddd",
- PdID: "sss",
- SuitType: 1,
- Month: 1,
- SubType: 1,
- OPrice: 1,
- Selected: 1,
- Remark: "",
- Status: 0,
- Operator: "sss",
- OpID: 1,
- StartBuild: 200,
- EndBuild: 300,
- }
- err := d.AddVipPriceConfig(context.TODO(), v)
- So(err, ShouldBeNil)
- })
- Convey("Test_AddVipPriceConfig add build 0-0", t, func() {
- v := &model.VipPriceConfig{
- Plat: 10,
- PdName: "ddd",
- PdID: "sss",
- SuitType: 1,
- Month: 1,
- SubType: 1,
- OPrice: 1,
- Selected: 1,
- Remark: "",
- Status: 0,
- Operator: "sss",
- OpID: 1,
- StartBuild: 200,
- EndBuild: 300,
- }
- err := d.AddVipPriceConfig(context.TODO(), v)
- So(err, ShouldBeNil)
- })
- }
- func TestDaoAddVipDPriceConfig(t *testing.T) {
- Convey("Test_AddVipPriceConfig", t, func() {
- v := &model.VipDPriceConfig{
- DisID: 1,
- ID: 1,
- PdID: "sss",
- DPrice: 1,
- STime: xtime.Time(time.Now().Unix()),
- Remark: "",
- Operator: "sss",
- OpID: 1,
- }
- err := d.AddVipDPriceConfig(context.TODO(), v)
- So(err, ShouldBeNil)
- })
- }
- func TestUpVipPriceConfig(t *testing.T) {
- Convey("TestUpVipPriceConfig", t, func() {
- err := d.UpVipPriceConfig(context.TODO(), &model.VipPriceConfig{
- ID: 230,
- Plat: 10,
- PdName: "ddd",
- PdID: "sss",
- SuitType: 1,
- Month: 1,
- SubType: 1,
- OPrice: 1,
- Selected: 1,
- Remark: "",
- Status: 0,
- Operator: "sss",
- OpID: 1,
- StartBuild: 250,
- EndBuild: 300,
- })
- So(err, ShouldBeNil)
- })
- }
- func TestDaoUpVipPriceConfig(t *testing.T) {
- Convey("Test_UpVipPriceConfig", t, func() {
- v := &model.VipPriceConfig{
- ID: 1,
- Plat: 1,
- PdName: "ddd",
- PdID: "sss",
- SuitType: 1,
- Month: 1,
- SubType: 2,
- OPrice: 1,
- Selected: 1,
- Remark: "",
- Status: 0,
- Operator: "sss",
- OpID: 1,
- }
- err := d.AddVipPriceConfig(context.TODO(), v)
- So(err, ShouldBeNil)
- })
- }
- func TestDaoUpVipDPriceConfig(t *testing.T) {
- Convey("Test_UpVipDPriceConfig", t, func() {
- v := &model.VipDPriceConfig{
- DisID: 1,
- ID: 1,
- PdID: "sss",
- DPrice: 1,
- STime: xtime.Time(time.Now().Unix()),
- Remark: "",
- Operator: "sss",
- OpID: 1,
- }
- err := d.UpVipDPriceConfig(context.TODO(), v)
- So(err, ShouldBeNil)
- })
- }
- func TestDaoDelVipPriceConfig(t *testing.T) {
- Convey("Test_DelVipPriceConfig", t, func() {
- err := d.DelVipPriceConfig(context.TODO(), &model.ArgVipPriceID{ID: 1})
- So(err, ShouldBeNil)
- })
- }
- func TestDaoDelVipDPriceConfig(t *testing.T) {
- Convey("Test_DelVipDPriceConfig", t, func() {
- err := d.DelVipDPriceConfig(context.TODO(), &model.ArgVipDPriceID{DisID: 1})
- So(err, ShouldBeNil)
- })
- }
- func TestDaoVipPriceConfigUQCheck(t *testing.T) {
- Convey("Test_VipPriceConfigUQCheck", t, func() {
- res, err := d.VipPriceConfigUQCheck(context.TODO(), &model.ArgAddOrUpVipPrice{Plat: 1, Month: 1, SubType: 1, SuitType: 0})
- So(err, ShouldBeNil)
- So(res, ShouldNotBeNil)
- })
- Convey("Test_VipPriceConfigUQCheck count 0-0", t, func() {
- count, err := d.VipPriceConfigUQCheck(context.TODO(), &model.ArgAddOrUpVipPrice{Plat: 10, Month: 1, SubType: 1, SuitType: 1})
- fmt.Println("count:", count)
- So(err, ShouldBeNil)
- So(count, ShouldNotBeNil)
- })
- Convey("Test_VipPriceConfigUQCheck count 220-0", t, func() {
- count, err := d.VipPriceConfigUQCheck(context.TODO(), &model.ArgAddOrUpVipPrice{Plat: 10, Month: 1, SubType: 1, SuitType: 1, StartBuild: 220, EndBuild: 0})
- fmt.Println("count:", count)
- So(err, ShouldBeNil)
- So(count, ShouldNotBeNil)
- })
- Convey("Test_VipPriceConfigUQCheck count 120-180", t, func() {
- count, err := d.VipPriceConfigUQCheck(context.TODO(), &model.ArgAddOrUpVipPrice{Plat: 10, Month: 1, SubType: 1, SuitType: 1, StartBuild: 120, EndBuild: 180})
- fmt.Println("count:", count)
- So(err, ShouldBeNil)
- So(count, ShouldNotBeNil)
- })
- Convey("Test_VipPriceConfigUQCheck count 0-180", t, func() {
- count, err := d.VipPriceConfigUQCheck(context.TODO(), &model.ArgAddOrUpVipPrice{Plat: 10, Month: 1, SubType: 1, SuitType: 1, StartBuild: 0, EndBuild: 180})
- fmt.Println("count:", count)
- So(err, ShouldBeNil)
- So(count, ShouldNotBeNil)
- })
- Convey("Test_VipPriceConfigUQCheck count 0-600", t, func() {
- count, err := d.VipPriceConfigUQCheck(context.TODO(), &model.ArgAddOrUpVipPrice{Plat: 10, Month: 1, SubType: 1, SuitType: 1, StartBuild: 0, EndBuild: 600})
- fmt.Println("count:", count)
- So(err, ShouldBeNil)
- So(count, ShouldNotBeNil)
- })
- }
- func TestDaoVipPriceConfigs(t *testing.T) {
- Convey("Test_VipPriceConfigs", t, func() {
- count, err := d.VipPriceConfigs(context.TODO())
- So(err, ShouldBeNil)
- So(count, ShouldNotBeEmpty)
- })
- }
- func TestDaoVipPriceConfigID(t *testing.T) {
- Convey("Test_VipPriceConfigID", t, func() {
- ids, err := d.VipPriceConfigID(context.TODO(), &model.ArgVipPriceID{ID: 1})
- So(err, ShouldBeNil)
- So(ids, ShouldNotBeEmpty)
- })
- }
- func TestDaoVipDPriceConfigs(t *testing.T) {
- Convey("Test_VipDPriceConfigs", t, func() {
- count, err := d.VipDPriceConfigs(context.TODO(), &model.ArgVipPriceID{ID: 1})
- So(err, ShouldBeNil)
- So(count, ShouldNotBeEmpty)
- })
- }
- func TestDaoVipDPriceConfigID(t *testing.T) {
- Convey("Test_VipDPriceConfigID", t, func() {
- res, err := d.VipDPriceConfigID(context.TODO(), &model.ArgVipDPriceID{DisID: 1})
- So(err, ShouldBeNil)
- So(res, ShouldNotBeEmpty)
- })
- }
- func TestDaoVipDPriceConfigUQTime(t *testing.T) {
- Convey("Test_VipDPriceConfigUQTime", t, func() {
- arg := &model.ArgAddOrUpVipDPrice{
- ID: 992,
- STime: xtime.Time(time.Now().Unix()),
- ETime: xtime.Time(time.Now().Unix()),
- }
- _, err := d.VipDPriceConfigUQTime(context.TODO(), arg)
- So(err, ShouldBeNil)
- })
- }
- func TestDaoVipPriceDiscountConfigs(t *testing.T) {
- Convey("Test_VipPriceDiscountConfigs", t, func() {
- res, err := d.VipPriceDiscountConfigs(context.TODO())
- So(err, ShouldBeNil)
- So(res, ShouldNotBeEmpty)
- })
- }
- func TestDaoVipMaxPriceDiscount(t *testing.T) {
- Convey("Test_VipMaxPriceDiscount", t, func() {
- res, err := d.VipMaxPriceDiscount(context.TODO(), &model.ArgAddOrUpVipPrice{ID: 1})
- So(err, ShouldBeNil)
- So(res, ShouldNotBeEmpty)
- })
- }
- func TestDaoCountVipPriceConfigByPlat(t *testing.T) {
- Convey("TestDaoCountVipPriceConfigByPlat", t, func() {
- res, err := d.CountVipPriceConfigByPlat(context.TODO(), 1)
- fmt.Println(res)
- So(err, ShouldBeNil)
- So(res, ShouldBeGreaterThanOrEqualTo, 0)
- })
- }
|