rank_test.go 616 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package rank
  2. import (
  3. "context"
  4. "flag"
  5. "go-common/app/interface/main/app-show/conf"
  6. "path/filepath"
  7. "testing"
  8. "time"
  9. . "github.com/smartystreets/goconvey/convey"
  10. )
  11. var (
  12. s *Service
  13. )
  14. func WithService(f func(s *Service)) func() {
  15. return func() {
  16. f(s)
  17. }
  18. }
  19. func init() {
  20. dir, _ := filepath.Abs("../../cmd/app-show-test.toml")
  21. flag.Set("conf", dir)
  22. conf.Init()
  23. s = New(conf.Conf)
  24. time.Sleep(time.Second)
  25. }
  26. func TestRankShow(t *testing.T) {
  27. Convey("get RankShow data", t, WithService(func(s *Service) {
  28. res := s.RankShow(context.TODO(), 0, 1, 1, 20, 0, "all")
  29. So(res, ShouldNotBeEmpty)
  30. }))
  31. }