task_test.go 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/admin/main/dm/model"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestServiceTaskList(t *testing.T) {
  9. convey.Convey("TaskList", t, func(ctx convey.C) {
  10. var (
  11. c = context.Background()
  12. v = &model.TaskListArg{
  13. Pn: 1,
  14. Ps: 10,
  15. }
  16. )
  17. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  18. res, err := svr.TaskList(c, v)
  19. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  20. ctx.So(err, convey.ShouldBeNil)
  21. ctx.So(res, convey.ShouldNotBeNil)
  22. for _, v := range res.Result {
  23. t.Logf("=====%+v", v)
  24. }
  25. })
  26. })
  27. })
  28. }
  29. func TestServiceAddTask(t *testing.T) {
  30. convey.Convey("AddTask", t, func(ctx convey.C) {
  31. var (
  32. c = context.Background()
  33. v = &model.AddTaskArg{
  34. IPs: "172.1.1.1",
  35. Start: "2016-10-30 16:12:21",
  36. End: "2018-10-30 16:12:21",
  37. OpTime: "2018-10-30 16:12:21",
  38. }
  39. )
  40. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  41. err := svr.AddTask(c, v)
  42. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  43. ctx.So(err, convey.ShouldBeNil)
  44. })
  45. })
  46. })
  47. }
  48. func TestServiceEditTaskState(t *testing.T) {
  49. convey.Convey("EditTaskState", t, func(ctx convey.C) {
  50. var (
  51. c = context.Background()
  52. v = &model.EditTasksStateArg{
  53. IDs: "7",
  54. State: 3,
  55. }
  56. )
  57. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  58. err := svr.EditTaskState(c, v)
  59. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  60. ctx.So(err, convey.ShouldBeNil)
  61. })
  62. })
  63. })
  64. }
  65. func TestServiceTaskView(t *testing.T) {
  66. convey.Convey("TaskView", t, func(ctx convey.C) {
  67. var (
  68. c = context.Background()
  69. v = &model.TaskViewArg{
  70. ID: int64(7),
  71. }
  72. )
  73. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  74. task, err := svr.TaskView(c, v)
  75. ctx.Convey("Then err should be nil.task should not be nil.", func(ctx convey.C) {
  76. ctx.So(err, convey.ShouldBeNil)
  77. ctx.So(task, convey.ShouldNotBeNil)
  78. t.Logf("====%+v\n", task)
  79. t.Logf("====%+v", task.SubTask)
  80. })
  81. })
  82. })
  83. }
  84. func TestServiceReviewTask(t *testing.T) {
  85. convey.Convey("ReviewTask", t, func(ctx convey.C) {
  86. var (
  87. c = context.Background()
  88. v = &model.ReviewTaskArg{
  89. ID: 21,
  90. }
  91. )
  92. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  93. err := svr.ReviewTask(c, v)
  94. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  95. ctx.So(err, convey.ShouldBeNil)
  96. })
  97. })
  98. })
  99. }