service_test.go 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package service
  2. import (
  3. "context"
  4. "flag"
  5. . "github.com/smartystreets/goconvey/convey"
  6. "path/filepath"
  7. "testing"
  8. "time"
  9. "go-common/app/job/main/videoup-report/conf"
  10. "go-common/app/job/main/videoup-report/model/archive"
  11. )
  12. var (
  13. s *Service
  14. )
  15. func init() {
  16. dir, _ := filepath.Abs("../cmd/videoup-report-job.toml")
  17. flag.Set("conf", dir)
  18. conf.Init()
  19. s = New(conf.Conf)
  20. }
  21. func Test_loadType(t *testing.T) {
  22. Convey("loadType", t, func() {
  23. s.loadType()
  24. })
  25. }
  26. func Test_VideoAudit(t *testing.T) {
  27. Convey("VideoAudit", t, func() {
  28. _, err := s.VideoAudit(context.Background(), time.Now(), time.Now())
  29. So(err, ShouldBeNil)
  30. })
  31. }
  32. func Test_Ping(t *testing.T) {
  33. Convey("Ping", t, func() {
  34. err := s.Ping(context.Background())
  35. So(err, ShouldBeNil)
  36. })
  37. }
  38. func Test_TaskTooksByHalfHour(t *testing.T) {
  39. Convey("TaskTooksByHalfHour", t, func() {
  40. _, err := s.TaskTooksByHalfHour(context.Background(), time.Now(), time.Now())
  41. So(err, ShouldBeNil)
  42. })
  43. }
  44. func Test_AddArchiveHotRecheck(t *testing.T) {
  45. Convey("AddArchiveHotRecheck", t, func() {
  46. time.Sleep(time.Second)
  47. err := s.addHotRecheck()
  48. So(err, ShouldBeNil)
  49. })
  50. }
  51. func Test_SecondRound(t *testing.T) {
  52. Convey("SecondRound", t, func() {
  53. m := &archive.VideoupMsg{
  54. Route: "second_round",
  55. Aid: 24320325,
  56. FromList: "hot_review",
  57. }
  58. err := s.secondRound(context.Background(), m)
  59. So(err, ShouldBeNil)
  60. })
  61. }
  62. func Test_SecondRoundCancelMission(t *testing.T) {
  63. Convey("SecondRound", t, func() {
  64. m := &archive.VideoupMsg{
  65. Route: "second_round",
  66. Aid: 17191032,
  67. MissionID: 1,
  68. }
  69. err := s.secondRound(context.Background(), m)
  70. So(err, ShouldBeNil)
  71. })
  72. }
  73. func Test_SecondFormat(t *testing.T) {
  74. Convey("SecondFormat", t, func() {
  75. m := 5556
  76. format := secondsFormat(m)
  77. So(format, ShouldNotBeNil)
  78. })
  79. }