up_base_info_test.go 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. package upcrmservice
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/admin/main/up/model/upcrmmodel"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestUpcrmserviceUpBaseInfoQuery(t *testing.T) {
  9. convey.Convey("UpBaseInfoQuery", t, func(ctx convey.C) {
  10. var (
  11. context = context.Background()
  12. arg = &upcrmmodel.InfoQueryArgs{}
  13. )
  14. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  15. result, err := s.UpBaseInfoQuery(context, arg)
  16. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  17. ctx.So(err, convey.ShouldBeNil)
  18. ctx.So(result, convey.ShouldNotBeNil)
  19. })
  20. })
  21. })
  22. }
  23. func TestUpcrmserviceupBaseInfoQueryBatch(t *testing.T) {
  24. convey.Convey("upBaseInfoQueryBatch", t, func(ctx convey.C) {
  25. var (
  26. queryfunc QueryDbFunc
  27. ids = int64(0)
  28. )
  29. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  30. result, err := s.upBaseInfoQueryBatch(queryfunc, ids)
  31. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  32. ctx.So(err, convey.ShouldBeNil)
  33. ctx.So(result, convey.ShouldNotBeNil)
  34. })
  35. })
  36. })
  37. }
  38. func TestUpcrmserviceUpAccountInfo(t *testing.T) {
  39. convey.Convey("UpAccountInfo", t, func(ctx convey.C) {
  40. var (
  41. con = context.Background()
  42. arg = &upcrmmodel.InfoAccountInfoArgs{}
  43. )
  44. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  45. result, err := s.UpAccountInfo(con, arg)
  46. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  47. ctx.So(err, convey.ShouldBeNil)
  48. ctx.So(result, convey.ShouldNotBeNil)
  49. })
  50. })
  51. })
  52. }
  53. func TestUpcrmservicegetAttrFormat(t *testing.T) {
  54. convey.Convey("getAttrFormat", t, func(ctx convey.C) {
  55. var (
  56. attrs upcrmmodel.UpAttr
  57. )
  58. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  59. result := getAttrFormat(attrs)
  60. ctx.Convey("Then result should not be nil.", func(ctx convey.C) {
  61. ctx.So(result, convey.ShouldNotBeNil)
  62. })
  63. })
  64. })
  65. }
  66. func TestUpcrmservicegetEsCombo(t *testing.T) {
  67. convey.Convey("getEsCombo", t, func(ctx convey.C) {
  68. var (
  69. attrs upcrmmodel.UpAttr
  70. )
  71. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  72. combos := getEsCombo(attrs)
  73. ctx.Convey("Then combos should not be nil.", func(ctx convey.C) {
  74. ctx.So(combos, convey.ShouldNotBeNil)
  75. })
  76. })
  77. })
  78. }
  79. func TestUpcrmserviceUpInfoSearch(t *testing.T) {
  80. convey.Convey("UpInfoSearch", t, func(ctx convey.C) {
  81. var (
  82. c = context.Background()
  83. arg = &upcrmmodel.InfoSearchArgs{}
  84. )
  85. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  86. result, err := s.UpInfoSearch(c, arg)
  87. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  88. ctx.So(err, convey.ShouldBeNil)
  89. ctx.So(result, convey.ShouldNotBeNil)
  90. })
  91. })
  92. })
  93. }
  94. func TestUpcrmserviceToPageInfo(t *testing.T) {
  95. convey.Convey("ToPageInfo", t, func(ctx convey.C) {
  96. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  97. var p = esPage{}
  98. pageInfo := p.ToPageInfo()
  99. ctx.Convey("Then pageInfo should not be nil.", func(ctx convey.C) {
  100. ctx.So(pageInfo, convey.ShouldNotBeNil)
  101. })
  102. })
  103. })
  104. }
  105. func TestUpcrmservicesearchFromEs(t *testing.T) {
  106. convey.Convey("searchFromEs", t, func(ctx convey.C) {
  107. var (
  108. c = context.Background()
  109. arg = &upcrmmodel.InfoSearchArgs{}
  110. )
  111. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  112. searchData, err := s.searchFromEs(c, arg)
  113. ctx.Convey("Then err should be nil.searchData should not be nil.", func(ctx convey.C) {
  114. ctx.So(err, convey.ShouldBeNil)
  115. ctx.So(searchData, convey.ShouldNotBeNil)
  116. })
  117. })
  118. })
  119. }
  120. func TestUpcrmservicequeryUpBaseInfo(t *testing.T) {
  121. convey.Convey("queryUpBaseInfo", t, func(ctx convey.C) {
  122. var (
  123. c = context.Background()
  124. ids = int64(0)
  125. )
  126. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  127. result, err := s.queryUpBaseInfo(c, ids)
  128. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  129. ctx.So(err, convey.ShouldBeNil)
  130. ctx.So(result, convey.ShouldNotBeNil)
  131. })
  132. })
  133. })
  134. }
  135. func TestUpcrmserviceQueryUpInfoWithViewerData(t *testing.T) {
  136. convey.Convey("QueryUpInfoWithViewerData", t, func(ctx convey.C) {
  137. var (
  138. c = context.Background()
  139. arg = &upcrmmodel.UpInfoWithViewerArg{}
  140. )
  141. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  142. result, err := s.QueryUpInfoWithViewerData(c, arg)
  143. ctx.Convey("Then err should be nil.result should not be nil.", func(ctx convey.C) {
  144. ctx.So(err, convey.ShouldBeNil)
  145. ctx.So(result, convey.ShouldNotBeNil)
  146. })
  147. })
  148. })
  149. }
  150. func TestUpcrmservicegetOrCreateUpInfo(t *testing.T) {
  151. convey.Convey("getOrCreateUpInfo", t, func(ctx convey.C) {
  152. var (
  153. dataMap map[int64]*upcrmmodel.UpInfoWithViewerData
  154. mid = int64(0)
  155. )
  156. ctx.Convey("When everything goes positive", func(ctx convey.C) {
  157. result := getOrCreateUpInfo(dataMap, mid)
  158. ctx.Convey("Then result should not be nil.", func(ctx convey.C) {
  159. ctx.So(result, convey.ShouldNotBeNil)
  160. })
  161. })
  162. })
  163. }