notice_test.go 708 B

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