archive_test.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. package service
  2. import (
  3. "context"
  4. . "github.com/smartystreets/goconvey/convey"
  5. "testing"
  6. "go-common/app/admin/main/videoup/model/archive"
  7. )
  8. func TestService_Submit(t *testing.T) {
  9. var (
  10. c = context.TODO()
  11. ap = &archive.ArcParam{}
  12. )
  13. Convey("Submit", t, WithService(func(s *Service) {
  14. err := svr.Submit(c, ap)
  15. So(err, ShouldBeNil)
  16. }))
  17. }
  18. func TestService_UpAccess(t *testing.T) {
  19. var (
  20. c = context.TODO()
  21. ap = &archive.ArcParam{}
  22. )
  23. Convey("UpAccess", t, WithService(func(s *Service) {
  24. err := svr.UpAccess(c, ap)
  25. So(err, ShouldBeNil)
  26. }))
  27. }
  28. func TestService_UpArcDtime(t *testing.T) {
  29. var (
  30. c = context.TODO()
  31. )
  32. Convey("UpArcDtime", t, WithService(func(s *Service) {
  33. err := svr.UpArcDtime(c, 1, 12345)
  34. So(err, ShouldNotBeNil)
  35. }))
  36. }
  37. func TestService_UpAuther(t *testing.T) {
  38. var (
  39. c = context.TODO()
  40. ap = &archive.ArcParam{}
  41. )
  42. Convey("UpAuther", t, WithService(func(s *Service) {
  43. err := svr.UpAuther(c, ap)
  44. So(err, ShouldBeNil)
  45. }))
  46. }
  47. func TestService_UpArchiveAttr(t *testing.T) {
  48. var (
  49. c = context.TODO()
  50. )
  51. attrs := make(map[uint]int32, 6)
  52. attrs[archive.AttrBitNoRank] = 0
  53. attrs[archive.AttrBitNoDynamic] = 0
  54. attrs[archive.AttrBitNoRecommend] = 0
  55. // forbid
  56. forbidAttrs := make(map[string]map[uint]int32, 3)
  57. forbidAttrs[archive.ForbidRank] = map[uint]int32{
  58. archive.ForbidRankMain: 0,
  59. archive.ForbidRankRecentArc: 0,
  60. archive.ForbidRankAllArc: 0,
  61. }
  62. forbidAttrs[archive.ForbidDynamic] = map[uint]int32{
  63. archive.ForbidDynamicMain: 0,
  64. }
  65. forbidAttrs[archive.ForbidRecommend] = map[uint]int32{
  66. archive.ForbidRecommendMain: 0,
  67. }
  68. Convey("UpArchiveAttr", t, WithService(func(s *Service) {
  69. err := svr.UpArchiveAttr(c, 1, 2, attrs, forbidAttrs, "")
  70. So(err, ShouldBeNil)
  71. }))
  72. }
  73. func TestService_Next(t *testing.T) {
  74. var (
  75. c = context.TODO()
  76. )
  77. Convey("Next", t, WithService(func(s *Service) {
  78. task, err := svr.Next(c, 6)
  79. So(task, ShouldNotBeNil)
  80. So(err, ShouldBeNil)
  81. }))
  82. }
  83. func TestService_UpArcTag(t *testing.T) {
  84. Convey("UpArcTag", t, WithService(func(s *Service) {
  85. //a.频道回查列表进入并提交的 b.tag改变
  86. c := context.TODO()
  87. //pm1(~a && b) -- archive_oper新增记录
  88. pm1 := &archive.TagParam{AID: 6, Tags: "haha1,haha2", FromChannelReview: ""}
  89. //pm2 (~a && ~b) -- 啥都没有
  90. pm2 := &archive.TagParam{AID: 6, Tags: "haha1,haha2", FromChannelReview: ""}
  91. //pm1(a && ~b) -- 新增flow_design
  92. pm3 := &archive.TagParam{AID: 6, Tags: "haha1,haha2", FromChannelReview: "1"}
  93. //pm2 (a && b) -- archive_oper新增
  94. pm4 := &archive.TagParam{AID: 6, Tags: "haha", FromChannelReview: "1"}
  95. err := svr.UpArcTag(c, 421, pm1)
  96. So(err, ShouldBeNil)
  97. err = svr.UpArcTag(c, 421, pm2)
  98. So(err, ShouldBeNil)
  99. err = svr.UpArcTag(c, 421, pm3)
  100. So(err, ShouldNotBeNil)
  101. err = svr.UpArcTag(c, 421, pm4)
  102. So(err, ShouldNotBeNil)
  103. }))
  104. }
  105. func TestService_GetChannelInfo(t *testing.T) {
  106. Convey("GetChannelInfo", t, WithService(func(s *Service) {
  107. info, err := s.GetChannelInfo(context.TODO(), []int64{10110255, 10110250})
  108. for aid, in := range info {
  109. channes := []*archive.Channel{}
  110. if in != nil {
  111. channes = in.Channels
  112. }
  113. t.Logf("aid=%d, in=%+v list the channels\r\n", aid, in)
  114. for _, ch := range channes {
  115. t.Logf("channel(%+v)\r\n", ch)
  116. }
  117. }
  118. So(err, ShouldBeNil)
  119. }))
  120. }