task_test.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. package mc
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/admin/main/aegis/model/common"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestMcConsumerOn(t *testing.T) {
  9. convey.Convey("ConsumerOn", t, func(ctx convey.C) {
  10. var (
  11. opt = &common.BaseOptions{}
  12. )
  13. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  14. err := d.ConsumerOn(context.TODO(), opt)
  15. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  16. ctx.So(err, convey.ShouldBeNil)
  17. })
  18. })
  19. })
  20. }
  21. func TestMcConsumerOff(t *testing.T) {
  22. convey.Convey("ConsumerOff", t, func(ctx convey.C) {
  23. var (
  24. opt = &common.BaseOptions{}
  25. )
  26. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  27. err := d.ConsumerOff(context.TODO(), opt)
  28. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  29. ctx.So(err, convey.ShouldBeNil)
  30. })
  31. })
  32. })
  33. }
  34. func TestMcIsConsumerOn(t *testing.T) {
  35. convey.Convey("IsConsumerOn", t, func(ctx convey.C) {
  36. var (
  37. opt = &common.BaseOptions{}
  38. )
  39. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  40. _, err := d.IsConsumerOn(context.TODO(), opt)
  41. ctx.Convey("Then err should be nil.", func(ctx convey.C) {
  42. ctx.So(err, convey.ShouldBeNil)
  43. })
  44. })
  45. })
  46. }
  47. func TestMcmcKey(t *testing.T) {
  48. convey.Convey("mcKey", t, func(ctx convey.C) {
  49. var (
  50. opt = &common.BaseOptions{}
  51. )
  52. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  53. p1 := mcKey(opt)
  54. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  55. ctx.So(p1, convey.ShouldNotBeNil)
  56. })
  57. })
  58. })
  59. }
  60. func TestMcroleKey(t *testing.T) {
  61. convey.Convey("roleKey", t, func(ctx convey.C) {
  62. var (
  63. opt = &common.BaseOptions{}
  64. )
  65. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  66. p1 := roleKey(opt)
  67. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  68. ctx.So(p1, convey.ShouldNotBeNil)
  69. })
  70. })
  71. })
  72. }
  73. func TestMcSetRole(t *testing.T) {
  74. convey.Convey("SetRole", t, func(ctx convey.C) {
  75. var (
  76. c = context.TODO()
  77. opt = &common.BaseOptions{}
  78. )
  79. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  80. err := d.SetRole(c, opt, 0)
  81. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  82. ctx.So(err, convey.ShouldBeNil)
  83. })
  84. })
  85. })
  86. }
  87. func TestMcGetRole(t *testing.T) {
  88. convey.Convey("GetRole", t, func(ctx convey.C) {
  89. var (
  90. c = context.TODO()
  91. opt = &common.BaseOptions{}
  92. )
  93. ctx.Convey("When everything gose positive", func(ctx convey.C) {
  94. _, _, err := d.GetRole(c, opt)
  95. ctx.Convey("Then p1 should not be nil.", func(ctx convey.C) {
  96. ctx.So(err, convey.ShouldBeNil)
  97. })
  98. })
  99. })
  100. }