client_test.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. package client
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "go-common/app/service/main/resource/model"
  7. )
  8. func TestResource(t *testing.T) {
  9. s := New(nil)
  10. time.Sleep(2 * time.Second)
  11. testResourceAll(t, s)
  12. testAssignmentAll(t, s)
  13. testDefBanner(t, s)
  14. testResource(t, s)
  15. testResources(t, s)
  16. testBanners(t, s)
  17. testPasterAPP(t, s)
  18. testIndexIcon(t, s)
  19. testPlayerIcon(t, s)
  20. testCmtbox(t, s)
  21. testSideBars(t, s)
  22. testAbTest(t, s)
  23. testPasterCID(t, s)
  24. }
  25. // testResourceAll test rpc ResourceAll.
  26. func testResourceAll(t *testing.T, s *Service) {
  27. res, err := s.ResourceAll(context.TODO())
  28. if err != nil {
  29. t.Logf("testResourceAll error(%v) \n", err)
  30. return
  31. }
  32. t.Logf("testResourceAll res: %+v \n", res)
  33. }
  34. // testAssignmentAll test rpc AssignmentAll.
  35. func testAssignmentAll(t *testing.T, s *Service) {
  36. res, err := s.AssignmentAll(context.TODO())
  37. if err != nil {
  38. t.Logf("testAssignmentAll error(%v) \n", err)
  39. return
  40. }
  41. t.Logf("testAssignmentAll res: %+v \n", res)
  42. }
  43. // testDefBanner test rpc DefBanner.
  44. func testDefBanner(t *testing.T, s *Service) {
  45. res, err := s.DefBanner(context.TODO())
  46. if err != nil {
  47. t.Logf("testDefBanner error(%v) \n", err)
  48. return
  49. }
  50. t.Logf("testDefBanner res: %+v \n", res)
  51. }
  52. // testResource test rpc Resource.
  53. func testResource(t *testing.T, s *Service) {
  54. p := &model.ArgRes{
  55. ResID: 1233,
  56. }
  57. res, err := s.Resource(context.TODO(), p)
  58. if err != nil {
  59. t.Logf("testResource error(%v) \n", err)
  60. return
  61. }
  62. t.Logf("testResource res: %+v \n", res)
  63. }
  64. // testResources test rpc Resources.
  65. func testResources(t *testing.T, s *Service) {
  66. p := &model.ArgRess{
  67. ResIDs: []int{1187, 1639},
  68. }
  69. res, err := s.Resources(context.TODO(), p)
  70. if err != nil {
  71. t.Logf("testResources error(%v) \n", err)
  72. return
  73. }
  74. t.Logf("testResources res: %+v \n", res)
  75. }
  76. // testBanners test rpc Banners.
  77. func testBanners(t *testing.T, s *Service) {
  78. ab := &model.ArgBanner{
  79. Plat: 1,
  80. ResIDs: "454,467",
  81. Build: 508000,
  82. MID: 1493031,
  83. Channel: "abc",
  84. IP: "211.139.80.6",
  85. Buvid: "123",
  86. Network: "wifi",
  87. MobiApp: "iphone",
  88. Device: "test",
  89. IsAd: true,
  90. OpenEvent: "abc",
  91. }
  92. res, err := s.Banners(context.TODO(), ab)
  93. if err != nil {
  94. t.Logf("testBanners error(%v) \n", err)
  95. return
  96. }
  97. t.Logf("testBanners res: %+v \n", res)
  98. }
  99. // testPasterAPP test rpc Paster.
  100. func testPasterAPP(t *testing.T, s *Service) {
  101. p := &model.ArgPaster{
  102. Platform: int8(4),
  103. AdType: int8(1),
  104. Aid: "10097274",
  105. TypeId: "11",
  106. Buvid: "666666",
  107. }
  108. res, err := s.PasterAPP(context.TODO(), p)
  109. if err != nil {
  110. t.Logf("testPasterAPP error(%v) \n", err)
  111. return
  112. }
  113. t.Logf("testPaster res: %+v \n", res)
  114. }
  115. // testIndexIcon test rpc IndexIcon.
  116. func testIndexIcon(t *testing.T, s *Service) {
  117. res, err := s.IndexIcon(context.TODO())
  118. if err != nil {
  119. t.Logf("testIndexIcon error(%v) \n", err)
  120. return
  121. }
  122. t.Logf("testIndexIcon res: %+v \n", res)
  123. }
  124. // testPlayerIcon test rpc PlayerIcon.
  125. func testPlayerIcon(t *testing.T, s *Service) {
  126. res, err := s.PlayerIcon(context.TODO())
  127. if err != nil {
  128. t.Logf("testPlayerIcon error(%v) \n", err)
  129. return
  130. }
  131. t.Logf("testPlayerIcon res: %+v \n", res)
  132. }
  133. // testCmtbox test rpc Resource.
  134. func testCmtbox(t *testing.T, s *Service) {
  135. p := &model.ArgCmtbox{
  136. ID: 1,
  137. }
  138. res, err := s.Cmtbox(context.TODO(), p)
  139. if err != nil {
  140. t.Logf("testCmtbox error(%v) \n", err)
  141. return
  142. }
  143. t.Logf("testCmtbox res: %+v \n", res)
  144. }
  145. // testSideBars test rpc SideBars.
  146. func testSideBars(t *testing.T, s *Service) {
  147. res, err := s.SideBars(context.TODO())
  148. if err != nil {
  149. t.Logf("testSideBars error(%v) \n", err)
  150. return
  151. }
  152. t.Logf("testSideBars res: %+v \n", res)
  153. }
  154. // testAbTest test rpc abtest.
  155. func testAbTest(t *testing.T, s *Service) {
  156. p := &model.ArgAbTest{
  157. Groups: "不显示热门tab,显示热门tab",
  158. IP: "127.0.0.1",
  159. }
  160. res, err := s.AbTest(context.TODO(), p)
  161. if err != nil {
  162. t.Logf("testAbTest error(%v) \n", err)
  163. return
  164. }
  165. t.Logf("testAbTest res: %+v \n", res)
  166. }
  167. // testPasterCID test rpc PasterCID
  168. func testPasterCID(t *testing.T, s *Service) {
  169. res, err := s.PasterCID(context.TODO())
  170. if err != nil {
  171. t.Logf("testPasterCID error(%v) \n", err)
  172. return
  173. }
  174. t.Logf("testPasterCID res: %+v \n", res)
  175. }