123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- package mysql
- import (
- "context"
- "testing"
- "time"
- "go-common/app/admin/main/aegis/model/common"
- modtask "go-common/app/admin/main/aegis/model/task"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestMysqlTaskFromDB(t *testing.T) {
- convey.Convey("TaskFromDB", t, func(ctx convey.C) {
- var (
- id = int64(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- task, err := d.TaskFromDB(cntx, id)
- ctx.Convey("Then err should be nil.task should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(task, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestMysqlDispatchByID(t *testing.T) {
- convey.Convey("DispatchByID", t, func(ctx convey.C) {
- var (
- mtasks map[int64]*modtask.Task
- ids = []int64{0}
- args = interface{}(int64(0))
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- missids, err := d.DispatchByID(cntx, mtasks, ids, args)
- ctx.Convey("Then err should be nil.missids should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(missids, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestMysqlDBDispatch(t *testing.T) {
- convey.Convey("DBDispatch", t, func(ctx convey.C) {
- var (
- opt = &modtask.NextOptions{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- _, count, err := d.DBDispatch(cntx, opt)
- ctx.Convey("Then err should be nil.tasks,count should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(count, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestMysqlRelease(t *testing.T) {
- convey.Convey("Release", t, func(ctx convey.C) {
- var (
- opt = &common.BaseOptions{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rows, err := d.Release(cntx, opt, true)
- 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 TestMysqlSeize(t *testing.T) {
- convey.Convey("Seize", t, func(ctx convey.C) {
- var (
- c = context.Background()
- mapids = map[int64]int64{1: 1}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- count, err := d.Seize(c, mapids)
- ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(count, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestMysqlDelay(t *testing.T) {
- convey.Convey("Delay", t, func(ctx convey.C) {
- var (
- opt = &modtask.DelayOptions{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- rows, err := d.Delay(cntx, opt)
- 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 TestMysqlListCheckUnSeized(t *testing.T) {
- convey.Convey("ListCheckUnSeized", t, func(ctx convey.C) {
- var (
- mtasks = map[int64]*modtask.Task{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- _, err := d.ListCheckUnSeized(cntx, mtasks, []int64{})
- ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestMysqlListCheckSeized(t *testing.T) {
- convey.Convey("ListCheckSeized", t, func(ctx convey.C) {
- var (
- mtasks = map[int64]*modtask.Task{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- _, err := d.ListCheckSeized(cntx, mtasks, []int64{}, int64(1))
- ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestMysqlListCheckDelay(t *testing.T) {
- convey.Convey("ListCheckDelay", t, func(ctx convey.C) {
- var (
- mtasks = map[int64]*modtask.Task{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- _, err := d.ListCheckDelay(cntx, mtasks, []int64{}, int64(1))
- ctx.Convey("Then err should be nil.rows should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestMysqlListTasks(t *testing.T) {
- convey.Convey("ListTasks", t, func(ctx convey.C) {
- opt := &modtask.ListOptions{
- State: 4,
- }
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- _, _, err := d.ListTasks(context.TODO(), opt)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestMysqllistCheck(t *testing.T) {
- convey.Convey("listCheck", t, func(ctx convey.C) {
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- _, err := d.listCheck(context.TODO(), "state=1", []int64{1})
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestMysqlConsumerOn(t *testing.T) {
- convey.Convey("ConsumerOn", t, func(ctx convey.C) {
- var (
- c = context.Background()
- opt = &common.BaseOptions{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.ConsumerOn(c, opt)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestMysqlConsumerOff(t *testing.T) {
- convey.Convey("ConsumerOff", t, func(ctx convey.C) {
- var (
- c = context.Background()
- opt = &common.BaseOptions{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.ConsumerOff(c, opt)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestMysqlIsConsumerOn(t *testing.T) {
- convey.Convey("IsConsumerOn", t, func(ctx convey.C) {
- var (
- c = context.Background()
- opt = &common.BaseOptions{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- on, err := d.IsConsumerOn(c, opt)
- ctx.Convey("Then err should be nil.on should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(on, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestMysqlconsumer(t *testing.T) {
- convey.Convey("consumer", t, func(ctx convey.C) {
- var (
- c = context.Background()
- opt = &common.BaseOptions{}
- action = int8(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := d.consumer(c, opt, action)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestMysqlConsumerStat(t *testing.T) {
- convey.Convey("ConsumerStat", t, func(ctx convey.C) {
- var (
- c = context.Background()
- bizid = int64(0)
- flowid = int64(0)
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- items, err := d.ConsumerStat(c, bizid, flowid)
- ctx.Convey("Then err should be nil.items should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(items, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestMysqlOnlines(t *testing.T) {
- convey.Convey("Onlines", t, func(ctx convey.C) {
- var (
- c = context.Background()
- opt = &common.BaseOptions{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- uids, err := d.Onlines(c, opt)
- ctx.Convey("Then err should be nil.uids should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(uids, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestMysqlQueryTask(t *testing.T) {
- convey.Convey("QueryTask", t, func(ctx convey.C) {
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- _, _, err := d.QueryTask(context.TODO(), 0, time.Now(), 0, 0)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestMysqlCountPersonal(t *testing.T) {
- convey.Convey("CountPersonal", t, func(ctx convey.C) {
- var (
- c = context.Background()
- opt = &common.BaseOptions{}
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- count, err := d.CountPersonal(c, opt)
- ctx.Convey("Then err should be nil.count should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(count, convey.ShouldNotBeNil)
- })
- })
- })
- }
- func TestMysqlQueryForSeize(t *testing.T) {
- convey.Convey("QueryForSeize", t, func(ctx convey.C) {
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- _, err := d.QueryForSeize(context.TODO(), 0, 0, 0, 0)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
|