123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- package gorm
- import (
- "context"
- "testing"
- "go-common/app/admin/main/aegis/model/common"
- taskmod "go-common/app/admin/main/aegis/model/task"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestUndoStat(t *testing.T) {
- convey.Convey("UndoStat", t, func(ctx convey.C) {
- var (
- c = context.Background()
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.UndoStat(c, 0, 0, 0)
- 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 TestTaskStat(t *testing.T) {
- convey.Convey("TaskStat", t, func(ctx convey.C) {
- var (
- c = context.Background()
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := d.TaskStat(c, 0, 0, 0)
- 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 TestTaskMaxWeight(t *testing.T) {
- convey.Convey("MaxWeight", t, func(ctx convey.C) {
- var (
- c = context.Background()
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- _, err := d.MaxWeight(c, 0, 0)
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestTaskListSeized(t *testing.T) {
- convey.Convey("TaskListSeized", t, func(ctx convey.C) {
- var (
- c = context.Background()
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- _, _, err := d.TaskListSeized(c, &taskmod.ListOptions{})
- ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestTxCloseTasks(t *testing.T) {
- convey.Convey("TxCloseTasks", t, func(ctx convey.C) {
- var (
- c = context.Background()
- tx, _ = d.BeginTx(c)
- )
- defer tx.Commit()
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- err := d.TxCloseTasks(tx, []int64{}, 0)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestTxSubmit(t *testing.T) {
- convey.Convey("TxSubmit", t, func(ctx convey.C) {
- var (
- tx, _ = d.BeginTx(cntx)
- opt = &taskmod.SubmitOptions{}
- )
- defer tx.Commit()
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- _, err := d.TxSubmit(tx, opt, 0)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestCloseTask(t *testing.T) {
- convey.Convey("CloseTask", t, func(ctx convey.C) {
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- err := d.CloseTask(cntx, 0)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestTaskByRID(t *testing.T) {
- convey.Convey("TaskByRID", t, func(ctx convey.C) {
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- _, err := d.TaskByRID(cntx, 0, 1)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestTaskListAssignd(t *testing.T) {
- convey.Convey("TaskListAssignd", t, func(ctx convey.C) {
- var (
- opt = &taskmod.ListOptions{}
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- _, _, err := d.TaskListAssignd(cntx, opt)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestTaskListDelayd(t *testing.T) {
- convey.Convey("TaskListDelayd", t, func(ctx convey.C) {
- var (
- opt = &taskmod.ListOptions{
- BaseOptions: common.BaseOptions{
- UID: 1,
- },
- }
- )
- ctx.Convey("When everything gose positive", func(ctx convey.C) {
- _, _, err := d.TaskListDelayd(cntx, opt)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
|