123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250 |
- package dao
- import (
- "context"
- "testing"
- "go-common/app/admin/main/manager/model"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestDaoAddCateSecExt(t *testing.T) {
- var (
- c = context.TODO()
- e = &model.CateSecExt{
- BusinessID: 1,
- Type: 1,
- Name: "测试type1",
- }
- )
- convey.Convey("AddCateSecExt", t, func(ctx convey.C) {
- err := d.AddCateSecExt(c, e)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoUpdateCateSecExt(t *testing.T) {
- var (
- c = context.TODO()
- e = &model.CateSecExt{
- ID: 75,
- Name: "测试更新下",
- }
- )
- convey.Convey("UpdateCateSecExt", t, func(ctx convey.C) {
- err := d.UpdateCateSecExt(c, e)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoBanCateSecExt(t *testing.T) {
- var (
- c = context.TODO()
- e = &model.CateSecExt{
- ID: 75,
- State: 0,
- }
- )
- convey.Convey("BanCateSecExt", t, func(ctx convey.C) {
- err := d.BanCateSecExt(c, e)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoAddAssociation(t *testing.T) {
- var (
- c = context.TODO()
- e = &model.Association{
- BusinessID: 1,
- RoleID: 121,
- CategoryID: 212,
- SecondIDs: "3,7",
- }
- )
- convey.Convey("AddAssociation", t, func(ctx convey.C) {
- err := d.AddAssociation(c, e)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoUpdateAssociation(t *testing.T) {
- var (
- c = context.TODO()
- e = &model.Association{
- ID: 41,
- RoleID: 1111,
- CategoryID: 2222,
- SecondIDs: "6,5,4,3",
- }
- )
- convey.Convey("UpdateAssociation", t, func(ctx convey.C) {
- err := d.UpdateAssociation(c, e)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoBanAssociation(t *testing.T) {
- var (
- c = context.TODO()
- e = &model.Association{
- ID: 41,
- State: 1,
- }
- )
- convey.Convey("BanAssociation", t, func(ctx convey.C) {
- err := d.BanAssociation(c, e)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoAddReason(t *testing.T) {
- var (
- c = context.TODO()
- e = &model.Reason{
- BusinessID: 1,
- RoleID: 99,
- CategoryID: 98,
- SecondID: 97,
- Common: 0,
- UID: 1,
- Description: "随便测试",
- Weight: 96,
- Flag: 0,
- }
- )
- convey.Convey("AddReason", t, func(ctx convey.C) {
- err := d.AddReason(c, e)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoUpdateReason(t *testing.T) {
- var (
- c = context.TODO()
- e = &model.Reason{
- ID: 18,
- RoleID: 100,
- CategoryID: 99,
- SecondID: 98,
- Common: 1,
- Description: "随便测试试试",
- Weight: 97,
- Flag: 1,
- BusinessID: 2,
- TypeID: 3,
- TagID: 4,
- }
- )
- convey.Convey("UpdateReason", t, func(ctx convey.C) {
- err := d.UpdateReason(c, e)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoReasonList(t *testing.T) {
- var (
- c = context.TODO()
- e = &model.SearchReasonParams{
- BusinessID: 1,
- }
- )
- convey.Convey("ReasonList", t, func(ctx convey.C) {
- res, err := d.ReasonList(c, e)
- 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 TestDaoCateSecByIDs(t *testing.T) {
- var (
- c = context.TODO()
- ids = []int64{1, 2, 3}
- )
- convey.Convey("CateSecByIDs", t, func(ctx convey.C) {
- res, err := d.CateSecByIDs(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 TestDaoBatchUpdateReasonState(t *testing.T) {
- var (
- c = context.TODO()
- b = &model.BatchUpdateReasonState{
- IDs: []int64{1, 2, 3},
- }
- )
- convey.Convey("BatchUpdateReasonState", t, func(ctx convey.C) {
- err := d.BatchUpdateReasonState(c, b)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- }
- func TestDaoCateSecExtList(t *testing.T) {
- var (
- c = context.TODO()
- e = &model.CateSecExt{
- BusinessID: 1,
- Type: 1,
- }
- )
- convey.Convey("CateSecExtList", t, func(ctx convey.C) {
- res, err := d.CateSecExtList(c, e)
- 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 TestDaoCateSecList(t *testing.T) {
- var (
- c = context.TODO()
- lid = int64(0)
- )
- convey.Convey("CateSecList", t, func(ctx convey.C) {
- res, err := d.CateSecList(c, lid)
- 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 TestDaoAssociationList(t *testing.T) {
- var (
- c = context.TODO()
- state = int64(0)
- lid = int64(0)
- )
- convey.Convey("AssociationList", t, func(ctx convey.C) {
- res, err := d.AssociationList(c, state, lid)
- 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)
- })
- })
- }
|