upper_test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. func Test_UpArticleMetas(t *testing.T) {
  8. Convey("get data", t, WithService(func(s *Service) {
  9. res, err := s.UpArticleMetas(context.TODO(), dataMID, 1, 20, 0)
  10. So(err, ShouldBeNil)
  11. So(res, ShouldNotBeEmpty)
  12. }))
  13. Convey("no data", t, WithService(func(s *Service) {
  14. res, err := s.UpArticleMetas(context.TODO(), dataMID, 20000, 20, 0)
  15. So(err, ShouldBeNil)
  16. So(res.Articles, ShouldBeEmpty)
  17. }))
  18. }
  19. func Test_UpsArticles(t *testing.T) {
  20. Convey("get data", t, WithService(func(s *Service) {
  21. res, err := s.UpsArticleMetas(context.TODO(), []int64{dataMID}, 1, 20)
  22. So(err, ShouldBeNil)
  23. So(res, ShouldNotBeEmpty)
  24. }))
  25. Convey("get count", t, WithService(func(s *Service) {
  26. res, err := s.UpperArtsCount(context.TODO(), dataMID)
  27. So(err, ShouldBeNil)
  28. So(res, ShouldBeGreaterThan, 0)
  29. }))
  30. Convey("no data", t, WithService(func(s *Service) {
  31. res, err := s.UpsArticleMetas(context.TODO(), []int64{dataID}, 20000, 20)
  32. So(err, ShouldBeNil)
  33. So(res[dataID], ShouldBeEmpty)
  34. }))
  35. }