history_test.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. "go-common/app/interface/main/history/model"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. // TestService_History
  10. func TestService_History(t *testing.T) {
  11. var (
  12. c = context.TODO()
  13. mid int64 = 14771787
  14. aid int64 = 5463823
  15. aids = []int64{5463823}
  16. sid int64 = 5730
  17. cid int64 = 97791
  18. epid int64 = 97922
  19. pro int64 = 155
  20. rtime int64 = 1490958549
  21. tp int8 = 1
  22. dt int8 = 2
  23. pn = 1
  24. ps = 100
  25. now = time.Now().Unix()
  26. h = &model.History{Aid: aid, Unix: now, Sid: sid, Epid: epid, Cid: cid, Pro: pro, TP: int8(tp), DT: int8(dt)}
  27. )
  28. Convey("history ", t, WithService(func(s *Service) {
  29. Convey("history AddHistory ", func() {
  30. err := s.AddHistory(c, mid, rtime, h)
  31. So(err, ShouldBeNil)
  32. })
  33. Convey("history Progress", func() {
  34. _, err := s.Progress(c, mid, aids)
  35. So(err, ShouldBeNil)
  36. })
  37. Convey("history DelHistory", func() {
  38. err := s.DelHistory(c, mid, aids, 3)
  39. So(err, ShouldBeNil)
  40. })
  41. Convey("history ClearHistory", func() {
  42. err := s.ClearHistory(c, mid, []int8{3})
  43. So(err, ShouldBeNil)
  44. })
  45. Convey("history Videos", func() {
  46. _, err := s.Videos(c, mid, pn, ps, 3)
  47. So(err, ShouldBeNil)
  48. })
  49. Convey("history AVHistories", func() {
  50. _, err := s.AVHistories(c, mid)
  51. So(err, ShouldBeNil)
  52. })
  53. Convey("history Histories", func() {
  54. _, err := s.Histories(c, mid, 1, 2, 3)
  55. So(err, ShouldBeNil)
  56. })
  57. Convey("history SetShadow", func() {
  58. err := s.SetShadow(c, mid, 1)
  59. So(err, ShouldBeNil)
  60. })
  61. Convey("history Shadow", func() {
  62. _, err := s.Shadow(c, mid)
  63. So(err, ShouldBeNil)
  64. })
  65. Convey("history Manager", func() {
  66. _, err := s.ManagerHistory(c, false, mid)
  67. So(err, ShouldBeNil)
  68. })
  69. }))
  70. }
  71. func TestService_AddHistory(t *testing.T) {
  72. var (
  73. c = context.TODO()
  74. mid int64 = 14771787
  75. aid int64 = 5463823
  76. sid int64 = 5730
  77. cid int64 = 97791
  78. epid int64 = 97922
  79. pro int64 = 155
  80. rtime int64 = 1490958549
  81. tp int8 = 1
  82. dt int8 = 2
  83. now = time.Now().Unix()
  84. h = &model.History{Aid: aid, Unix: now, Sid: sid, Epid: epid, Cid: cid, Pro: pro, TP: int8(tp), DT: int8(dt)}
  85. )
  86. Convey("history ", t, WithService(func(s *Service) {
  87. Convey("history AddHistory ", func() {
  88. err := s.AddHistory(c, mid, rtime, h)
  89. So(err, ShouldBeNil)
  90. })
  91. }))
  92. }