service_test.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package service
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "time"
  8. "go-common/app/admin/main/videoup/conf"
  9. "go-common/library/queue/databus/report"
  10. . "github.com/smartystreets/goconvey/convey"
  11. )
  12. var (
  13. svr *Service
  14. )
  15. func init() {
  16. dir, _ := filepath.Abs("../cmd/videoup-admin.toml")
  17. flag.Set("conf", dir)
  18. conf.Init()
  19. svr = New(conf.Conf)
  20. time.Sleep(time.Second)
  21. report.InitManager(conf.Conf.ManagerReport)
  22. }
  23. func WithService(f func(s *Service)) func() {
  24. return func() {
  25. f(svr)
  26. }
  27. }
  28. func TestService_Ping(t *testing.T) {
  29. var (
  30. c = context.TODO()
  31. )
  32. Convey("Ping", t, WithService(func(s *Service) {
  33. err := svr.Ping(c)
  34. So(err, ShouldBeNil)
  35. }))
  36. }
  37. func TestService_PGCWhite(t *testing.T) {
  38. Convey("PGCWhite", t, WithService(func(s *Service) {
  39. data := svr.PGCWhite(1)
  40. So(data, ShouldBeFalse)
  41. }))
  42. }
  43. func TestService_getallupgroups(t *testing.T) {
  44. Convey("getallupgroups", t, WithService(func(s *Service) {
  45. gs := s.getAllUPGroups(27515615)
  46. t.Logf("UPGroups(%+v)\r\n", gs)
  47. So(len(gs), ShouldBeGreaterThan, 0)
  48. }))
  49. }