sidebar_test.go 622 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package sidebar
  2. import (
  3. "context"
  4. "flag"
  5. "path/filepath"
  6. "testing"
  7. "time"
  8. "go-common/app/interface/main/app-resource/conf"
  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-resource-test.toml")
  21. flag.Set("conf", dir)
  22. conf.Init()
  23. s = New(conf.Conf)
  24. time.Sleep(time.Second)
  25. }
  26. func TestSideBar(t *testing.T) {
  27. Convey("get SideBar data", t, WithService(func(s *Service) {
  28. res := s.SideBar(context.TODO(), 1, 1, 1, 1, "hans")
  29. So(res, ShouldNotBeEmpty)
  30. }))
  31. }