mcn_test.go 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. adminmodel "go-common/app/admin/main/mcn/model"
  6. "go-common/app/interface/main/mcn/model"
  7. "go-common/app/interface/main/mcn/model/mcnmodel"
  8. "github.com/smartystreets/goconvey/convey"
  9. )
  10. func TestServicegetMcnWithState(t *testing.T) {
  11. convey.Convey("getMcnWithState", t, func(ctx convey.C) {
  12. var (
  13. c = context.Background()
  14. mcnmid = int64(0)
  15. state = model.MCNSignState(1)
  16. )
  17. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  18. mcnSign, err := s.getMcnWithState(c, mcnmid, state)
  19. ctx.Convey("Then err should be nil.mcnSign should not be nil.", func(ctx convey.C) {
  20. ctx.So(err, convey.ShouldBeNil)
  21. ctx.So(mcnSign, convey.ShouldNotBeNil)
  22. })
  23. })
  24. })
  25. }
  26. func TestServiceMcnGetState(t *testing.T) {
  27. convey.Convey("McnGetState", t, func(ctx convey.C) {
  28. var (
  29. c = context.Background()
  30. arg = &mcnmodel.GetStateReq{}
  31. )
  32. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  33. res, err := s.McnGetState(c, arg)
  34. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  35. ctx.So(err, convey.ShouldBeNil)
  36. ctx.So(res, convey.ShouldNotBeNil)
  37. })
  38. })
  39. })
  40. }
  41. func TestServiceMcnExist(t *testing.T) {
  42. convey.Convey("McnExist", t, func(ctx convey.C) {
  43. var (
  44. c = context.Background()
  45. arg = &mcnmodel.GetStateReq{}
  46. )
  47. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  48. res, err := s.McnExist(c, arg)
  49. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  50. ctx.So(err, convey.ShouldBeNil)
  51. ctx.So(res, convey.ShouldNotBeNil)
  52. })
  53. })
  54. })
  55. }
  56. func TestServiceMcnApply(t *testing.T) {
  57. convey.Convey("McnApply", t, func(ctx convey.C) {
  58. var (
  59. c = context.Background()
  60. arg = &mcnmodel.McnApplyReq{}
  61. )
  62. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  63. res, err := s.McnApply(c, arg)
  64. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  65. ctx.So(err, convey.ShouldBeNil)
  66. ctx.So(res, convey.ShouldNotBeNil)
  67. })
  68. })
  69. })
  70. }
  71. func TestServiceMcnBindUpApply(t *testing.T) {
  72. convey.Convey("McnBindUpApply", t, func(ctx convey.C) {
  73. var (
  74. c = context.Background()
  75. arg = &mcnmodel.McnBindUpApplyReq{}
  76. )
  77. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  78. res, err := s.McnBindUpApply(c, arg)
  79. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  80. ctx.So(err, convey.ShouldBeNil)
  81. ctx.So(res, convey.ShouldNotBeNil)
  82. })
  83. })
  84. })
  85. }
  86. func TestServiceMcnUpConfirm(t *testing.T) {
  87. convey.Convey("McnUpConfirm", t, func(ctx convey.C) {
  88. var (
  89. c = context.Background()
  90. arg = &mcnmodel.McnUpConfirmReq{}
  91. )
  92. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  93. res, err := s.McnUpConfirm(c, arg)
  94. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  95. ctx.So(err, convey.ShouldBeNil)
  96. ctx.So(res, convey.ShouldNotBeNil)
  97. })
  98. })
  99. })
  100. }
  101. func TestServiceMcnUpGetBind(t *testing.T) {
  102. convey.Convey("McnUpGetBind", t, func(ctx convey.C) {
  103. var (
  104. c = context.Background()
  105. arg = &mcnmodel.McnUpGetBindReq{}
  106. )
  107. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  108. res, err := s.McnUpGetBind(c, arg)
  109. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  110. ctx.So(err, convey.ShouldBeNil)
  111. ctx.So(res, convey.ShouldNotBeNil)
  112. })
  113. })
  114. })
  115. }
  116. func TestServiceMcnDataSummary(t *testing.T) {
  117. convey.Convey("McnDataSummary", t, func(ctx convey.C) {
  118. var (
  119. c = context.Background()
  120. arg = &mcnmodel.McnGetDataSummaryReq{}
  121. )
  122. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  123. res, err := s.McnDataSummary(c, arg)
  124. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  125. ctx.So(err, convey.ShouldBeNil)
  126. ctx.So(res, convey.ShouldNotBeNil)
  127. })
  128. })
  129. })
  130. }
  131. func TestServiceMcnDataUpList(t *testing.T) {
  132. convey.Convey("McnDataUpList", t, func(ctx convey.C) {
  133. var (
  134. c = context.Background()
  135. arg = &mcnmodel.McnGetUpListReq{}
  136. )
  137. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  138. res, err := s.McnDataUpList(c, arg)
  139. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  140. ctx.So(err, convey.ShouldBeNil)
  141. ctx.So(res, convey.ShouldNotBeNil)
  142. })
  143. })
  144. })
  145. }
  146. func TestServiceMcnGetOldInfo(t *testing.T) {
  147. convey.Convey("McnGetOldInfo", t, func(ctx convey.C) {
  148. var (
  149. c = context.Background()
  150. arg = &mcnmodel.McnGetMcnOldInfoReq{}
  151. )
  152. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  153. res, err := s.McnGetOldInfo(c, arg)
  154. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  155. ctx.So(err, convey.ShouldBeNil)
  156. ctx.So(res, convey.ShouldNotBeNil)
  157. })
  158. })
  159. })
  160. }
  161. func TestCheckPermission(t *testing.T) {
  162. convey.Convey("checkPermission", t, func(ctx convey.C) {
  163. var (
  164. c = context.Background()
  165. mcnMid, upMid int64 = 15555180, 27515410
  166. permissions = []adminmodel.AttrBasePermit{adminmodel.AttrBasePermitBit, adminmodel.AttrDataPermitBit}
  167. )
  168. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  169. res := s.checkPermission(c, mcnMid, upMid, permissions...)
  170. ctx.Convey("Then err should be nil.res should not be nil.", func(ctx convey.C) {
  171. ctx.So(res, convey.ShouldBeTrue)
  172. })
  173. })
  174. })
  175. }