show_test.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package show
  2. import (
  3. "context"
  4. "flag"
  5. "go-common/app/interface/main/app-show/conf"
  6. "go-common/app/interface/main/app-show/model"
  7. "path/filepath"
  8. "testing"
  9. "time"
  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-show-test.toml")
  22. flag.Set("conf", dir)
  23. conf.Init()
  24. s = New(conf.Conf)
  25. time.Sleep(time.Second)
  26. }
  27. func TestIndex(t *testing.T) {
  28. Convey("get Index data", t, WithService(func(s *Service) {
  29. res := s.Index(context.TODO(), 0, model.PlatIPhone, 0, "", "", "", "", "", "iphone", "phone", _initlanguage, "", false, time.Now())
  30. So(res, ShouldNotBeEmpty)
  31. }))
  32. }
  33. func TestChange(t *testing.T) {
  34. Convey("get Change data", t, WithService(func(s *Service) {
  35. res := s.Change(context.TODO(), 1, 1, 1, 1, "", "", "", "", "")
  36. So(res, ShouldNotBeEmpty)
  37. }))
  38. }
  39. func TestRegionChange(t *testing.T) {
  40. Convey("get RegionChange data", t, WithService(func(s *Service) {
  41. res := s.RegionChange(context.TODO(), 1, 1, 1, 1, "")
  42. So(res, ShouldNotBeEmpty)
  43. }))
  44. }
  45. func TestBangumiChange(t *testing.T) {
  46. Convey("get BangumiChange data", t, WithService(func(s *Service) {
  47. res := s.BangumiChange(context.TODO(), 1, 1)
  48. So(res, ShouldNotBeEmpty)
  49. }))
  50. }
  51. func TestFeedIndex(t *testing.T) {
  52. Convey("get FeedIndex data", t, WithService(func(s *Service) {
  53. res := s.FeedIndex(context.TODO(), 1, 1, 1, 1, 1, "", "", "", "", time.Now())
  54. So(res, ShouldNotBeEmpty)
  55. }))
  56. }