task_test.go 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. package gorm
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/admin/main/aegis/model/common"
  6. taskmod "go-common/app/admin/main/aegis/model/task"
  7. "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestUndoStat(t *testing.T) {
  10. convey.Convey("UndoStat", t, func(ctx convey.C) {
  11. var (
  12. c = context.Background()
  13. )
  14. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  15. res, err := d.UndoStat(c, 0, 0, 0)
  16. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldBeNil)
  18. ctx.So(res, convey.ShouldNotBeNil)
  19. })
  20. })
  21. })
  22. }
  23. func TestTaskStat(t *testing.T) {
  24. convey.Convey("TaskStat", t, func(ctx convey.C) {
  25. var (
  26. c = context.Background()
  27. )
  28. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  29. res, err := d.TaskStat(c, 0, 0, 0)
  30. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  31. ctx.So(err, convey.ShouldBeNil)
  32. ctx.So(res, convey.ShouldNotBeNil)
  33. })
  34. })
  35. })
  36. }
  37. func TestTaskMaxWeight(t *testing.T) {
  38. convey.Convey("MaxWeight", t, func(ctx convey.C) {
  39. var (
  40. c = context.Background()
  41. )
  42. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  43. _, err := d.MaxWeight(c, 0, 0)
  44. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  45. ctx.So(err, convey.ShouldBeNil)
  46. })
  47. })
  48. })
  49. }
  50. func TestTaskListSeized(t *testing.T) {
  51. convey.Convey("TaskListSeized", t, func(ctx convey.C) {
  52. var (
  53. c = context.Background()
  54. )
  55. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  56. _, _, err := d.TaskListSeized(c, &taskmod.ListOptions{})
  57. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  58. ctx.So(err, convey.ShouldBeNil)
  59. })
  60. })
  61. })
  62. }
  63. func TestTxCloseTasks(t *testing.T) {
  64. convey.Convey("TxCloseTasks", t, func(ctx convey.C) {
  65. var (
  66. c = context.Background()
  67. tx, _ = d.BeginTx(c)
  68. )
  69. defer tx.Commit()
  70. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  71. err := d.TxCloseTasks(tx, []int64{}, 0)
  72. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  73. ctx.So(err, convey.ShouldBeNil)
  74. })
  75. })
  76. })
  77. }
  78. func TestTxSubmit(t *testing.T) {
  79. convey.Convey("TxSubmit", t, func(ctx convey.C) {
  80. var (
  81. tx, _ = d.BeginTx(cntx)
  82. opt = &taskmod.SubmitOptions{}
  83. )
  84. defer tx.Commit()
  85. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  86. _, err := d.TxSubmit(tx, opt, 0)
  87. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  88. ctx.So(err, convey.ShouldBeNil)
  89. })
  90. })
  91. })
  92. }
  93. func TestCloseTask(t *testing.T) {
  94. convey.Convey("CloseTask", t, func(ctx convey.C) {
  95. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  96. err := d.CloseTask(cntx, 0)
  97. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  98. ctx.So(err, convey.ShouldBeNil)
  99. })
  100. })
  101. })
  102. }
  103. func TestTaskByRID(t *testing.T) {
  104. convey.Convey("TaskByRID", t, func(ctx convey.C) {
  105. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  106. _, err := d.TaskByRID(cntx, 0, 1)
  107. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  108. ctx.So(err, convey.ShouldBeNil)
  109. })
  110. })
  111. })
  112. }
  113. func TestTaskListAssignd(t *testing.T) {
  114. convey.Convey("TaskListAssignd", t, func(ctx convey.C) {
  115. var (
  116. opt = &taskmod.ListOptions{}
  117. )
  118. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  119. _, _, err := d.TaskListAssignd(cntx, opt)
  120. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  121. ctx.So(err, convey.ShouldBeNil)
  122. })
  123. })
  124. })
  125. }
  126. func TestTaskListDelayd(t *testing.T) {
  127. convey.Convey("TaskListDelayd", t, func(ctx convey.C) {
  128. var (
  129. opt = &taskmod.ListOptions{
  130. BaseOptions: common.BaseOptions{
  131. UID: 1,
  132. },
  133. }
  134. )
  135. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  136. _, _, err := d.TaskListDelayd(cntx, opt)
  137. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  138. ctx.So(err, convey.ShouldBeNil)
  139. })
  140. })
  141. })
  142. }