splash_test.go 955 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package splash
  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 TestDisplay(t *testing.T) {
  28. Convey("get Display data", t, WithService(func(s *Service) {
  29. res, _, err := s.Display(context.TODO(), model.PlatIPhone, 1, 1, 1, "", "", time.Now())
  30. So(res, ShouldNotBeEmpty)
  31. So(err, ShouldBeNil)
  32. }))
  33. }
  34. func TestBirthday(t *testing.T) {
  35. Convey("get Birthday data", t, WithService(func(s *Service) {
  36. res, err := s.Birthday(context.TODO(), model.PlatIPhone, 1, 1, "")
  37. So(res, ShouldNotBeEmpty)
  38. So(err, ShouldBeNil)
  39. }))
  40. }