sync_pgc_test.go 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package service
  2. import (
  3. "go-common/app/admin/main/tv/model"
  4. "testing"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestService_EpCheck(t *testing.T) {
  8. Convey("TestService_EpCheck test", t, WithService(func(s *Service) {
  9. var cont = model.Content{}
  10. // already passed to 7
  11. err := s.EpCheck(&model.Content{
  12. ID: 106396,
  13. State: 3,
  14. })
  15. So(err, ShouldBeNil)
  16. s.DB.Where("id=?", 106396).First(&cont)
  17. So(cont.State == 7, ShouldBeTrue)
  18. // reject to re_audit
  19. err = s.EpCheck(&model.Content{
  20. ID: 106396,
  21. State: 4,
  22. })
  23. So(err, ShouldBeNil)
  24. s.DB.Where("id=?", 106396).First(&cont)
  25. So(cont.State == 1, ShouldBeTrue)
  26. }))
  27. }
  28. func TestService_SeasonCheck(t *testing.T) {
  29. Convey("TestService_SeasonCheck test", t, WithService(func(s *Service) {
  30. var season = model.TVEpSeason{}
  31. // already passed to 7
  32. err := s.SeasonCheck(&model.TVEpSeason{
  33. ID: 296,
  34. Check: 1})
  35. So(err, ShouldBeNil)
  36. s.DB.Where("id=?", 296).First(&season)
  37. So(season.Check == 7, ShouldBeTrue)
  38. // reject to re_audit
  39. err = s.SeasonCheck(&model.TVEpSeason{
  40. ID: 296,
  41. Check: 0})
  42. So(err, ShouldBeNil)
  43. s.DB.Where("id=?", 296).First(&season)
  44. So(season.Check == 2, ShouldBeTrue)
  45. }))
  46. }
  47. func TestService_EpDel(t *testing.T) {
  48. Convey("TestService_EpDel test", t, WithService(func(s *Service) {
  49. var (
  50. cont = model.Content{}
  51. ep = model.TVEpContent{}
  52. epid = 5822
  53. )
  54. // delete
  55. err := s.EpDel(int64(epid), 1)
  56. s.DB.Where("epid=?", epid).First(&cont)
  57. s.DB.Where("id=?", epid).First(&ep)
  58. So(err, ShouldBeNil)
  59. So(cont.IsDeleted == 1, ShouldBeTrue)
  60. So(ep.IsDeleted == 1, ShouldBeTrue)
  61. // recover
  62. err = s.EpDel(30185, 0)
  63. s.DB.Where("epid=?", 30185).First(&cont)
  64. s.DB.Where("id=?", 30185).First(&ep)
  65. So(err, ShouldBeNil)
  66. So(cont.IsDeleted == 1, ShouldBeTrue)
  67. So(ep.IsDeleted == 1, ShouldBeTrue)
  68. }))
  69. }
  70. func TestService_SeasonRemove(t *testing.T) {
  71. Convey("TestService_SeasonRemove test", t, WithService(func(s *Service) {
  72. var (
  73. season = model.TVEpSeason{}
  74. seasonID = 20950
  75. )
  76. err := s.SeasonRemove(&model.TVEpSeason{
  77. ID: int64(seasonID),
  78. Check: 1,
  79. })
  80. s.DB.Where("id=?", seasonID).First(&season)
  81. So(err, ShouldBeNil)
  82. }))
  83. }