article_test.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package service
  2. import (
  3. "context"
  4. "encoding/json"
  5. "testing"
  6. "go-common/app/interface/main/web/conf"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. func TestService_ArticleList(t *testing.T) {
  10. Convey("test article list", t, WithService(func(s *Service) {
  11. aids := []int64{}
  12. rid := 2
  13. sort := 1
  14. mid := 27515256
  15. res, err := s.ArticleList(context.Background(), int64(rid), int64(mid), sort, 1, 20, aids)
  16. So(err, ShouldBeNil)
  17. So(len(res), ShouldBeGreaterThan, 0)
  18. Println(len(res))
  19. for _, v := range res {
  20. Printf("%d,%+v", v.ID, v)
  21. }
  22. }))
  23. }
  24. func TestService_ArticleUpList(t *testing.T) {
  25. Convey("test article up list", t, WithService(func(s *Service) {
  26. res, err := s.ArticleUpList(context.Background(), 90085)
  27. So(err, ShouldBeNil)
  28. So(len(res), ShouldEqual, conf.Conf.Rule.ArtUpListCnt)
  29. if bs, err := json.Marshal(res); err != nil {
  30. Printf("%+v", err)
  31. } else {
  32. Println(string(bs))
  33. }
  34. }))
  35. }
  36. func TestService_Categories(t *testing.T) {
  37. Convey("test categories", t, WithService(func(s *Service) {
  38. res, err := s.Categories(context.Background())
  39. So(err, ShouldBeNil)
  40. So(res, ShouldNotBeNil)
  41. for _, v := range *res {
  42. Printf("%+v", v)
  43. }
  44. }))
  45. }