archive_test.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package service
  2. import (
  3. "context"
  4. . "github.com/smartystreets/goconvey/convey"
  5. "testing"
  6. "go-common/app/job/main/videoup-report/model/archive"
  7. )
  8. func TestService_Addarchive(t *testing.T) {
  9. Convey("addarchive", t, func() {
  10. err := s.addArchive(context.Background(), &archive.VideoupMsg{
  11. Aid: 10,
  12. })
  13. t.Logf("err(%+v)", err)
  14. })
  15. }
  16. func TestService_Modifyarchive(t *testing.T) {
  17. Convey("Modifyarchive", t, func() {
  18. err := s.modifyArchive(context.Background(), &archive.VideoupMsg{
  19. Aid: 11,
  20. TagChange: true,
  21. AddVideos: true,
  22. })
  23. t.Logf("err(%+v)", err)
  24. })
  25. }
  26. func TestService_arcStateChange(t *testing.T) {
  27. var (
  28. err error
  29. state int64
  30. aid = int64(12)
  31. )
  32. Convey("arcStateChange", t, func() {
  33. a, _ := s.arc.ArchiveByAid(context.TODO(), aid)
  34. nw := &archive.Archive{
  35. ID: a.ID,
  36. State: archive.StateOpen,
  37. }
  38. old := &archive.Archive{
  39. ID: a.ID,
  40. State: archive.StateForbidRecicle,
  41. }
  42. err = s.dataDao.CloseReply(context.TODO(), a.ID, a.Mid)
  43. So(err, ShouldBeNil)
  44. //只允许关的情况下,状态联动从关-》开不起作用
  45. err = s.arcStateChange(nw, old, false)
  46. So(err, ShouldBeNil)
  47. state, err = s.dataDao.CheckReply(context.TODO(), nw.ID)
  48. So(err, ShouldBeNil)
  49. So(state, ShouldEqual, archive.ReplyOff)
  50. //只允许开的情况下,状态联动从关->开起作用
  51. err = s.arcStateChange(nw, old, true)
  52. So(err, ShouldBeNil)
  53. state, err = s.dataDao.CheckReply(context.TODO(), nw.ID)
  54. So(err, ShouldBeNil)
  55. So(state, ShouldEqual, archive.ReplyOn)
  56. //只允许开的情况下,状态联动从开->关不起作用
  57. err = s.arcStateChange(old, nw, true)
  58. So(err, ShouldBeNil)
  59. state, err = s.dataDao.CheckReply(context.TODO(), nw.ID)
  60. So(err, ShouldBeNil)
  61. So(state, ShouldEqual, archive.ReplyOn)
  62. //只允许关的情况下,状态联动从开->关起作用
  63. err = s.arcStateChange(old, nw, false)
  64. So(err, ShouldBeNil)
  65. state, err = s.dataDao.CheckReply(context.TODO(), nw.ID)
  66. So(err, ShouldBeNil)
  67. So(state, ShouldEqual, archive.ReplyOff)
  68. })
  69. }