archive2_test.go 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. package gorpc
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "time"
  7. "go-common/app/service/main/archive/api"
  8. "go-common/app/service/main/archive/model/archive"
  9. )
  10. func TestDynamic(t *testing.T) {
  11. s := New2(nil)
  12. time.Sleep(5 * time.Second)
  13. testArchivesWithPlayer(t, s)
  14. testMaxAID(t, s)
  15. testVideo3(t, s)
  16. testUpsArcs3(t, s)
  17. testUpArcs3(t, s)
  18. testRecommend3(t, s)
  19. testArchive3(t, s)
  20. testArchives3(t, s)
  21. testAidPTime(t, s)
  22. testTypes2(t, s)
  23. testVideoshot2(t, s)
  24. testUpCount2(t, s)
  25. testView3(t, s)
  26. testViews3(t, s)
  27. testClick3(t, s)
  28. testRankArcs3(t, s)
  29. testRanksArcs3(t, s)
  30. testRankTopArcs3(t, s)
  31. testRankAllArcs3(t, s)
  32. testPage3(t, s)
  33. testRanksTopCount2(t, s)
  34. testStat3(t, s)
  35. testStats3(t, s)
  36. testArcCache2(t, s)
  37. testArcFieldCache2(t, s)
  38. testSetStat2(t, s)
  39. testUpVideo2(t, s)
  40. testDelVideo2(t, s)
  41. testDescription2(t, s)
  42. }
  43. func testViews3(t *testing.T, s *Service2) {
  44. var vs, err = s.Views3(context.TODO(), &archive.ArgAids2{Aids: []int64{10097450, 10097454}})
  45. if err != nil {
  46. t.Log(err)
  47. return
  48. }
  49. for _, v := range vs {
  50. t.Log(v.Archive3)
  51. }
  52. }
  53. func testClick3(t *testing.T, s *Service2) {
  54. t.Log(s.Click3(context.TODO(), &archive.ArgAid2{Aid: 10097454}))
  55. }
  56. func testRankArcs3(t *testing.T, s *Service2) {
  57. t.Log(s.RankArcs3(context.TODO(), &archive.ArgRank2{Rid: 20, Type: 0, Ps: 20, Pn: 1}))
  58. }
  59. func testRanksArcs3(t *testing.T, s *Service2) {
  60. t.Log(s.RanksArcs3(context.TODO(), &archive.ArgRanks2{Rids: []int16{20, 24}, Type: 0, Ps: 20, Pn: 1}))
  61. }
  62. func testRankTopArcs3(t *testing.T, s *Service2) {
  63. t.Log(s.RankTopArcs3(context.TODO(), &archive.ArgRankTop2{ReID: 1, Pn: 1, Ps: 10}))
  64. }
  65. func testRankAllArcs3(t *testing.T, s *Service2) {
  66. am, err := s.RankAllArcs3(context.TODO(), &archive.ArgRankAll2{Pn: 1, Ps: 40})
  67. if err != nil {
  68. t.Log(err)
  69. return
  70. }
  71. t.Logf("allRankTop(%d)", am.Count)
  72. for _, arc := range am.Archives {
  73. t.Logf("archive(%+v)", arc)
  74. }
  75. }
  76. func testAidPTime(t *testing.T, s *Service2) {
  77. res, err := s.UpsPassed2(context.TODO(), &archive.ArgUpsArcs2{Mids: []int64{15555180, 27515256}})
  78. fmt.Println(len(res))
  79. if err != nil {
  80. t.Logf("s.UpsPassed2 error(%v)", err)
  81. return
  82. }
  83. for mid, v := range res {
  84. t.Logf("mid:%d", mid)
  85. for _, aidAndPtime := range v {
  86. t.Logf("mid:%d, aid:%d, ptime:%d, copyright:%d", mid, aidAndPtime.Aid, aidAndPtime.PubDate, aidAndPtime.Copyright)
  87. }
  88. }
  89. }
  90. func testArchivesWithPlayer(t *testing.T, s *Service2) {
  91. arg := &archive.ArgPlayer{Aids: []int64{10097272, 1}, Qn: 16, Platform: "html5", RealIP: "222.73.196.18"}
  92. res, err := s.ArchivesWithPlayer(context.TODO(), arg)
  93. if err != nil {
  94. t.Logf("s.ArchivesWithPlayer(%+v) error(%v)", arg, err)
  95. return
  96. }
  97. for k, v := range res {
  98. t.Logf("aid:%d, arc:%+v, player:%+v", k, v, v.PlayerInfo)
  99. }
  100. }
  101. func testVideo3(t *testing.T, s *Service2) {
  102. t.Log(s.Video3(context.TODO(), &archive.ArgVideo2{Aid: 10097760, Cid: 10107336}))
  103. }
  104. func testRecommend3(t *testing.T, s *Service2) {
  105. for i := 0; i < 50; i++ {
  106. time.Sleep(100 * time.Millisecond)
  107. res, err := s.Recommend3(context.TODO(), &archive.ArgAid2{Aid: 4052562})
  108. if err != nil {
  109. t.Logf("s.Recommend3 error(%v)", err)
  110. continue
  111. }
  112. t.Log(res)
  113. }
  114. }
  115. func testArchive3(t *testing.T, s *Service2) {
  116. res, err := s.Archive3(context.TODO(), &archive.ArgAid2{Aid: 5463609})
  117. if err != nil {
  118. t.Logf("s.Archive3 error(%v)", err)
  119. return
  120. }
  121. t.Log(res)
  122. }
  123. func testArchives3(t *testing.T, s *Service2) {
  124. res, err := s.Archives3(context.TODO(), &archive.ArgAids2{Aids: []int64{5463609, 5463608, 10097657}})
  125. if err != nil {
  126. t.Logf("s.Archives3 error(%v)", err)
  127. return
  128. }
  129. for _, a := range res {
  130. t.Log(a)
  131. }
  132. }
  133. func testMaxAID(t *testing.T, s *Service2) {
  134. res, err := s.MaxAID(context.TODO())
  135. if err != nil {
  136. t.Error(err)
  137. return
  138. }
  139. t.Logf("maxAID is %d", res)
  140. }
  141. func testTypes2(t *testing.T, s *Service2) {
  142. res, err := s.Types2(context.TODO())
  143. if err != nil {
  144. t.Error(err)
  145. return
  146. }
  147. for _, tp := range res {
  148. t.Log(tp)
  149. }
  150. }
  151. func testVideoshot2(t *testing.T, s *Service2) {
  152. res, err := s.Videoshot2(context.TODO(), &archive.ArgCid2{Cid: 10108203})
  153. t.Log(res, err)
  154. }
  155. func testUpArcs3(t *testing.T, s *Service2) {
  156. res, err := s.UpArcs3(context.TODO(), &archive.ArgUpArcs2{Mid: 27515615, Pn: 1, Ps: 20})
  157. if err != nil {
  158. t.Error(err)
  159. return
  160. }
  161. for _, a := range res {
  162. t.Log(a)
  163. }
  164. }
  165. func testUpCount2(t *testing.T, s *Service2) {
  166. count, err := s.UpCount2(context.TODO(), &archive.ArgUpCount2{Mid: 27515615})
  167. if err != nil {
  168. t.Error(err)
  169. return
  170. }
  171. t.Log(count)
  172. }
  173. func testUpsArcs3(t *testing.T, s *Service2) {
  174. res, err := s.UpsArcs3(context.TODO(), &archive.ArgUpsArcs2{Mids: []int64{27515615, 1684013}})
  175. if err != nil {
  176. t.Error(err)
  177. return
  178. }
  179. t.Log(res)
  180. }
  181. func testView3(t *testing.T, s *Service2) {
  182. t.Log(s.View3(context.TODO(), &archive.ArgAid2{Aid: 10098067}))
  183. }
  184. func testPage3(t *testing.T, s *Service2) {
  185. t.Log(s.Page3(context.TODO(), &archive.ArgAid2{Aid: 10097454}))
  186. }
  187. func testRanksTopCount2(t *testing.T, s *Service2) {
  188. t.Log(s.RanksTopCount2(context.TODO(), &archive.ArgRankTopsCount2{ReIDs: []int16{1, 2}}))
  189. }
  190. func testStat3(t *testing.T, s *Service2) {
  191. res, err := s.Stat3(context.TODO(), &archive.ArgAid2{Aid: 10989901})
  192. if err != nil {
  193. t.Errorf("testStats3 error(%v)", err)
  194. return
  195. }
  196. t.Log(res, 1)
  197. }
  198. func testStats3(t *testing.T, s *Service2) {
  199. res, err := s.Stats3(context.TODO(), &archive.ArgAids2{Aids: []int64{10989901, 10097453}})
  200. if err != nil {
  201. t.Logf("testStats3 error(%v)", err)
  202. return
  203. }
  204. for aid, r := range res {
  205. t.Logf("%d:%+v\n", aid, r)
  206. }
  207. }
  208. func testArcCache2(t *testing.T, s *Service2) {
  209. t.Log(s.ArcCache2(context.TODO(), &archive.ArgCache2{Aid: 10097454, Tp: archive.CacheUpdate}))
  210. }
  211. func testArcFieldCache2(t *testing.T, s *Service2) {
  212. t.Log(s.ArcFieldCache2(context.TODO(), &archive.ArgFieldCache2{Aid: 10097454, TypeID: 20, OldTypeID: 10}))
  213. }
  214. func testSetStat2(t *testing.T, s *Service2) {
  215. t.Log(s.SetStat2(context.TODO(), &api.Stat{Aid: 10097454, View: 0, Danmaku: 0, Reply: 10, Fav: 10, Coin: 10, Share: 10, HisRank: 10, NowRank: 10}))
  216. }
  217. func testUpVideo2(t *testing.T, s *Service2) {
  218. t.Log(s.UpVideo2(context.TODO(), &archive.ArgVideo2{Aid: 10097760, Cid: 10107336}))
  219. }
  220. func testDelVideo2(t *testing.T, s *Service2) {
  221. t.Log(s.DelVideo2(context.TODO(), &archive.ArgVideo2{Aid: 10097760, Cid: 10107336}))
  222. }
  223. func testDescription2(t *testing.T, s *Service2) {
  224. t.Log(s.Description2(context.TODO(), &archive.ArgAid{Aid: 10097454}))
  225. }