123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- package service
- import (
- "context"
- "testing"
- "go-common/app/admin/main/dm/model"
- "github.com/smartystreets/goconvey/convey"
- )
- func TestServiceTaskList(t *testing.T) {
- convey.Convey("TaskList", t, func(ctx convey.C) {
- var (
- c = context.Background()
- v = &model.TaskListArg{
- Pn: 1,
- Ps: 10,
- }
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- res, err := svr.TaskList(c, v)
- 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)
- for _, v := range res.Result {
- t.Logf("=====%+v", v)
- }
- })
- })
- })
- }
- func TestServiceAddTask(t *testing.T) {
- convey.Convey("AddTask", t, func(ctx convey.C) {
- var (
- c = context.Background()
- v = &model.AddTaskArg{
- IPs: "172.1.1.1",
- Start: "2016-10-30 16:12:21",
- End: "2018-10-30 16:12:21",
- OpTime: "2018-10-30 16:12:21",
- }
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := svr.AddTask(c, v)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestServiceEditTaskState(t *testing.T) {
- convey.Convey("EditTaskState", t, func(ctx convey.C) {
- var (
- c = context.Background()
- v = &model.EditTasksStateArg{
- IDs: "7",
- State: 3,
- }
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := svr.EditTaskState(c, v)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
- func TestServiceTaskView(t *testing.T) {
- convey.Convey("TaskView", t, func(ctx convey.C) {
- var (
- c = context.Background()
- v = &model.TaskViewArg{
- ID: int64(7),
- }
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- task, err := svr.TaskView(c, v)
- ctx.Convey("Then err should be nil.task should not be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- ctx.So(task, convey.ShouldNotBeNil)
- t.Logf("====%+v\n", task)
- t.Logf("====%+v", task.SubTask)
- })
- })
- })
- }
- func TestServiceReviewTask(t *testing.T) {
- convey.Convey("ReviewTask", t, func(ctx convey.C) {
- var (
- c = context.Background()
- v = &model.ReviewTaskArg{
- ID: 21,
- }
- )
- ctx.Convey("When everything goes positive", func(ctx convey.C) {
- err := svr.ReviewTask(c, v)
- ctx.Convey("Then err should be nil.", func(ctx convey.C) {
- ctx.So(err, convey.ShouldBeNil)
- })
- })
- })
- }
|