123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353 |
- package dao
- import (
- "context"
- "testing"
- "go-common/app/admin/main/workflow/model"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestDaoChall(t *testing.T) {
- convey.Convey("Chall", t, func(ctx convey.C) {
- var (
- c = context.Background()
- cid = int64(1)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- chall, err := d.Chall(c, cid)
- ctx.Convey("Then err should be nil.chall should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(chall, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoChalls(t *testing.T) {
- convey.Convey("Challs", t, func(ctx convey.C) {
- var (
- c = context.Background()
- cids = []int64{1}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- challs, err := d.Challs(c, cids)
- ctx.Convey("Then err should be nil.challs should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(challs, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoStateChalls(t *testing.T) {
- convey.Convey("StateChalls", t, func(ctx convey.C) {
- var (
- c = context.Background()
- cids = []int64{1}
- state = int8(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- challs, err := d.StateChalls(c, cids, state)
- ctx.Convey("Then err should be nil.challs should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(challs, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoLastChallIDsByGids(t *testing.T) {
- convey.Convey("LastChallIDsByGids", t, func(ctx convey.C) {
- var (
- c = context.Background()
- gids = []int64{1}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- cids, err := d.LastChallIDsByGids(c, gids)
- ctx.Convey("Then err should be nil.cids should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(cids, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoTxUpChall(t *testing.T) {
- convey.Convey("TxUpChall", t, func(ctx convey.C) {
- var (
- tx = d.ORM.Begin()
- chall = &model.Chall{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rows, err := d.TxUpChall(tx, chall)
- err1 := tx.Commit().Error
- defer func() {
- if err != nil {
- tx.Rollback()
- }
- }()
- ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(err1, convey.ShouldBeNil)
- ctx.So(rows, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoTxBatchUpChallByIDs(t *testing.T) {
- convey.Convey("TxBatchUpChallByIDs", t, func(ctx convey.C) {
- var (
- tx = d.ORM.Begin()
- cids = []int64{1}
- state = int8(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.TxBatchUpChallByIDs(tx, cids, state)
- err1 := tx.Commit().Error
- defer func() {
- if err != nil {
- tx.Rollback()
- }
- }()
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(err1, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoAttPathsByCids(t *testing.T) {
- convey.Convey("AttPathsByCids", t, func(ctx convey.C) {
- var (
- c = context.Background()
- cids = []int64{1}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- paths, err := d.AttPathsByCids(c, cids)
- ctx.Convey("Then err should be nil.paths should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(paths, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoAttPathsByCid(t *testing.T) {
- convey.Convey("AttPathsByCid", t, func(ctx convey.C) {
- var (
- c = context.Background()
- cid = int64(1)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- paths, err := d.AttPathsByCid(c, cid)
- ctx.Convey("Then err should be nil.paths should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(paths, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoUpChallBusState(t *testing.T) {
- convey.Convey("UpChallBusState", t, func(ctx convey.C) {
- var (
- c = context.Background()
- cid = int64(1)
- busState = int8(1)
- assigneeAdminid = int64(1)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.UpChallBusState(c, cid, busState, assigneeAdminid)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoBatchUpChallBusState(t *testing.T) {
- convey.Convey("BatchUpChallBusState", t, func(ctx convey.C) {
- var (
- c = context.Background()
- cids = []int64{1}
- busState = int8(1)
- assigneeAdminid = int64(1)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.BatchUpChallBusState(c, cids, busState, assigneeAdminid)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoTxChallsByBusStates(t *testing.T) {
- convey.Convey("TxChallsByBusStates", t, func(ctx convey.C) {
- var (
- tx = d.ORM.Begin()
- business = int8(1)
- oid = int64(1)
- busStates = []int8{1}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- cids, err := d.TxChallsByBusStates(tx, business, oid, busStates)
- err1 := tx.Commit().Error
- defer func() {
- if err != nil {
- tx.Rollback()
- }
- }()
- ctx.Convey("Then err should be nil.cids should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(err1, convey.ShouldBeNil)
- ctx.So(cids, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoTxUpChallsBusStateByIDs(t *testing.T) {
- convey.Convey("TxUpChallsBusStateByIDs", t, func(ctx convey.C) {
- var (
- tx = d.ORM.Begin()
- cids = []int64{1}
- busState = int8(1)
- assigneeAdminid = int64(1)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.TxUpChallsBusStateByIDs(tx, cids, busState, assigneeAdminid)
- err1 := tx.Commit().Error
- defer func() {
- if err != nil {
- tx.Rollback()
- }
- }()
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(err1, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoTxUpChallExtraV2(t *testing.T) {
- convey.Convey("TxUpChallExtraV2", t, func(ctx convey.C) {
- var (
- tx = d.ORM.Begin()
- business = int8(1)
- oid = int64(1)
- adminid = int64(1)
- extra map[string]interface{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rows, err := d.TxUpChallExtraV2(tx, business, oid, adminid, extra)
- err1 := tx.Commit().Error
- defer func() {
- if err != nil {
- tx.Rollback()
- }
- }()
- ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(err1, convey.ShouldBeNil)
- ctx.So(rows, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestDaoUpExtraV3(t *testing.T) {
- convey.Convey("UpExtraV3", t, func(ctx convey.C) {
- var (
- gids = []int64{1}
- adminid = int64(1)
- extra = "test extra"
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.UpExtraV3(gids, adminid, extra)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoTxUpChallTag(t *testing.T) {
- convey.Convey("TxUpChallTag", t, func(ctx convey.C) {
- var (
- tx = d.ORM.Begin()
- cid = int64(1)
- tid = int64(1)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.TxUpChallTag(tx, cid, tid)
- err1 := tx.Commit().Error
- defer func() {
- if err != nil {
- tx.Rollback()
- }
- }()
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(err1, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoBatchUpChallByIDs(t *testing.T) {
- convey.Convey("BatchUpChallByIDs", t, func(ctx convey.C) {
- var (
- cids = []int64{1}
- dispatchState = uint32(1)
- adminid = int64(1)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.BatchUpChallByIDs(cids, dispatchState, adminid)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoBatchResetAssigneeAdminID(t *testing.T) {
- convey.Convey("BatchResetAssigneeAdminID", t, func(ctx convey.C) {
- var (
- cids = []int64{1}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.BatchResetAssigneeAdminID(cids)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestDaoTxUpChallAssignee(t *testing.T) {
- convey.Convey("TxUpChallAssignee", t, func(ctx convey.C) {
- var (
- tx = d.ORM.Begin()
- cids = []int64{1}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.TxUpChallAssignee(tx, cids)
- err1 := tx.Commit().Error
- defer func() {
- if err != nil {
- tx.Rollback()
- }
- }()
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(err1, convey.ShouldBeNil)
- })
- })
- })
- }
|