subject_test.go 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. package service
  2. import (
  3. "context"
  4. "fmt"
  5. "testing"
  6. "go-common/app/admin/main/activity/model"
  7. xtime "go-common/library/time"
  8. "time"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. func TestService_SubjectList(t *testing.T) {
  12. Convey("service test", t, WithService(func(s *Service) {
  13. p := &model.ListSub{
  14. Page: 1,
  15. PageSize: 15,
  16. Keyword: "layang123",
  17. States: []int{1},
  18. Types: []int{18},
  19. Sctime: 1534835169,
  20. Ectime: 1546272001,
  21. }
  22. list, err := s.SubjectList(context.Background(), p)
  23. So(err, ShouldBeNil)
  24. for _, v := range list.List {
  25. fmt.Printf("%+v", v)
  26. }
  27. }))
  28. }
  29. func TestService_VideoList(t *testing.T) {
  30. Convey("service test", t, WithService(func(s *Service) {
  31. list, err := s.VideoList(context.Background())
  32. So(err, ShouldBeNil)
  33. for _, v := range list {
  34. fmt.Printf("%+v %+v", v.ActSubject, v.Aids)
  35. }
  36. }))
  37. }
  38. func TestService_AddActSubject(t *testing.T) {
  39. Convey("service test", t, WithService(func(s *Service) {
  40. p := &model.AddList{
  41. ActSubject: model.ActSubject{
  42. Oid: 11,
  43. Type: 9,
  44. State: 1,
  45. Level: 5,
  46. Rank: 100,
  47. Stime: xtime.Time(time.Now().Unix()),
  48. Etime: xtime.Time(time.Now().Unix()),
  49. Ctime: xtime.Time(time.Now().Unix()),
  50. Mtime: xtime.Time(time.Now().Unix()),
  51. Lstime: xtime.Time(time.Now().Unix()),
  52. Letime: xtime.Time(time.Now().Unix()),
  53. Uetime: xtime.Time(time.Now().Unix()),
  54. Ustime: xtime.Time(time.Now().Unix()),
  55. Name: "test one",
  56. Author: "layang",
  57. ActURL: "http://www.baidu.com/",
  58. Cover: "cover",
  59. Flag: 128,
  60. Dic: "dif",
  61. H5Cover: "H5Cover",
  62. LikeLimit: 5,
  63. AndroidURL: "AndroidURL",
  64. IosURL: "IosURL",
  65. },
  66. Protocol: "Protocol",
  67. Types: "1,2,3",
  68. Pubtime: xtime.Time(time.Now().Unix()),
  69. Deltime: xtime.Time(time.Now().Unix()),
  70. Editime: xtime.Time(time.Now().Unix()),
  71. Tags: "由三",
  72. Interval: 1,
  73. Tlimit: 123,
  74. Ltime: 124,
  75. Hot: 1,
  76. BgmID: 3,
  77. PasterID: 4,
  78. Oids: "5,7,8",
  79. ScreenSet: 1,
  80. }
  81. res, err := s.AddActSubject(context.Background(), p)
  82. So(err, ShouldBeNil)
  83. fmt.Printf("%d", res)
  84. }))
  85. }
  86. func TestService_UpActSubject(t *testing.T) {
  87. Convey("service test", t, WithService(func(s *Service) {
  88. p := &model.AddList{
  89. ActSubject: model.ActSubject{
  90. Oid: 12,
  91. Type: 9,
  92. State: 0,
  93. Level: 6,
  94. Rank: 101,
  95. Stime: xtime.Time(time.Now().Unix()),
  96. Etime: xtime.Time(time.Now().Unix()),
  97. Ctime: xtime.Time(time.Now().Unix()),
  98. Mtime: xtime.Time(time.Now().Unix()),
  99. Lstime: xtime.Time(time.Now().Unix()),
  100. Letime: xtime.Time(time.Now().Unix()),
  101. Uetime: xtime.Time(time.Now().Unix()),
  102. Ustime: xtime.Time(time.Now().Unix()),
  103. Name: "test two",
  104. Author: "layang2",
  105. ActURL: "http://www.baidu.com/2",
  106. Cover: "cover2",
  107. Flag: 129,
  108. Dic: "dif2",
  109. H5Cover: "H5Cover2",
  110. LikeLimit: 6,
  111. AndroidURL: "AndroidURL2",
  112. IosURL: "IosURL2",
  113. },
  114. Protocol: "Protocol2",
  115. Types: "1,2,3,4",
  116. Pubtime: xtime.Time(time.Now().Unix()),
  117. Deltime: xtime.Time(time.Now().Unix()),
  118. Editime: xtime.Time(time.Now().Unix()),
  119. Tags: "由三2",
  120. Interval: 2,
  121. Tlimit: 124,
  122. Ltime: 125,
  123. Hot: 0,
  124. BgmID: 4,
  125. PasterID: 8,
  126. Oids: "5,7,8.9",
  127. ScreenSet: 2,
  128. }
  129. res, err := s.UpActSubject(context.Background(), p, 10298)
  130. So(err, ShouldBeNil)
  131. fmt.Printf("%+v", res)
  132. }))
  133. }
  134. func TestService_SubProtocol(t *testing.T) {
  135. Convey("sub protovol ", t, WithService(func(s *Service) {
  136. list, err := s.SubProtocol(context.Background(), 10256)
  137. So(err, ShouldBeNil)
  138. fmt.Printf("%+v", list)
  139. }))
  140. }
  141. func TestService_TimeConf(t *testing.T) {
  142. Convey("sub TimeConf ", t, WithService(func(s *Service) {
  143. list, err := s.TimeConf(context.Background(), 10298)
  144. So(err, ShouldBeNil)
  145. fmt.Printf("%+v", list)
  146. }))
  147. }
  148. func TestService_GetArticleMetas(t *testing.T) {
  149. Convey("sub TimeConf ", t, WithService(func(s *Service) {
  150. list, err := s.GetArticleMetas(context.Background(), []int64{1412})
  151. So(err, ShouldBeNil)
  152. fmt.Printf("%+v", list)
  153. }))
  154. }