feed_test.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package client
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. model "go-common/app/service/main/feed/model"
  7. )
  8. func TestFeed(t *testing.T) {
  9. s := New(nil)
  10. time.Sleep(1 * time.Second)
  11. testAppFeed(t, s)
  12. testWebFeed(t, s)
  13. testAddArc(t, s)
  14. testDelArc(t, s)
  15. testPurgeFeedCache(t, s)
  16. testFold(t, s)
  17. }
  18. func testAppFeed(t *testing.T, s *Service) {
  19. if res, err := s.AppFeed(context.TODO(), &model.ArgFeed{Mid: 27515256, Pn: 1, Ps: 20}); err != nil {
  20. t.Errorf("Service: AppFeed err: %v", err)
  21. } else {
  22. t.Logf("Service: AppFeed: %v", res)
  23. }
  24. }
  25. func testWebFeed(t *testing.T, s *Service) {
  26. if res, err := s.WebFeed(context.TODO(), &model.ArgFeed{Mid: 27515256, Pn: 1, Ps: 20}); err != nil {
  27. t.Errorf("Service: WebFeed err: %v", err)
  28. } else {
  29. t.Logf("Service: WebFeed: %v", res)
  30. }
  31. }
  32. func testArchiveFeed(t *testing.T, s *Service) {
  33. if res, err := s.ArchiveFeed(context.TODO(), &model.ArgFeed{Mid: 27515256, Pn: 1, Ps: 20}); err != nil {
  34. t.Errorf("Service: ArchiveFeed err: %v", err)
  35. } else {
  36. t.Logf("Service: ArchiveFeed: %v", res)
  37. }
  38. }
  39. func testBangumiFeed(t *testing.T, s *Service) {
  40. if res, err := s.BangumiFeed(context.TODO(), &model.ArgFeed{Mid: 27515256, Pn: 1, Ps: 20}); err != nil {
  41. t.Errorf("Service: BangumiFeed err: %v", err)
  42. } else {
  43. t.Logf("Service: BangumiFeed: %v", res)
  44. }
  45. }
  46. func testAddArc(t *testing.T, s *Service) {
  47. if err := s.AddArc(context.TODO(), &model.ArgArc{Aid: 1}); err != nil {
  48. t.Errorf("Service: AddArc err: %v", err)
  49. }
  50. }
  51. func testDelArc(t *testing.T, s *Service) {
  52. if err := s.DelArc(context.TODO(), &model.ArgAidMid{Aid: 1}); err != nil {
  53. t.Errorf("Service: DelArc err: %v", err)
  54. }
  55. }
  56. func testPurgeFeedCache(t *testing.T, s *Service) {
  57. if err := s.PurgeFeedCache(context.TODO(), &model.ArgMid{Mid: 27515256}); err != nil {
  58. t.Errorf("Service: PurgeFeedCache err: %v", err)
  59. }
  60. }
  61. func testFold(t *testing.T, s *Service) {
  62. if res, err := s.Fold(context.TODO(), &model.ArgFold{Aid: 1, Mid: 27515256}); err != nil {
  63. t.Errorf("Service: Fold err: %v", err)
  64. } else {
  65. t.Logf("Service: Fold: %v", res)
  66. }
  67. }
  68. func testAppUnreadCount(t *testing.T, s *Service) {
  69. if res, err := s.AppUnreadCount(context.TODO(), &model.ArgUnreadCount{Mid: 27515256, WithoutBangumi: false}); err != nil {
  70. t.Errorf("Service: UnreadCount err: %v", err)
  71. } else {
  72. t.Logf("Service: UnreadCount: %v", res)
  73. }
  74. }
  75. func testWebUnreadCount(t *testing.T, s *Service) {
  76. if res, err := s.WebUnreadCount(context.TODO(), &model.ArgMid{Mid: 27515256}); err != nil {
  77. t.Errorf("Service: UnreadCount err: %v", err)
  78. } else {
  79. t.Logf("Service: UnreadCount: %v", res)
  80. }
  81. }
  82. func testChangeArcUpper(t *testing.T, s *Service) {
  83. if err := s.ChangeArcUpper(context.TODO(), &model.ArgChangeUpper{Aid: 1, OldMid: 1, NewMid: 2, RealIP: "127.0.0.1"}); err != nil {
  84. t.Errorf("Service: ChangeArcUpper err: %v", err)
  85. } else {
  86. t.Logf("Service: ChangeArcUpper ok")
  87. }
  88. }