rank_test.go 1.1 KB

123456789101112131415161718192021222324252627
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. func Test_RankCategories(t *testing.T) {
  8. Convey("get data", t, func() {
  9. res := s.RankCategories(context.TODO())
  10. So(res, ShouldNotBeEmpty)
  11. })
  12. }
  13. func Test_Ranks(t *testing.T) {
  14. // data := `{"code":0,"source_date":"2018-01-02","list":[{"aid":1,"mid":137952,"score":565918,"view":176708,"reply":2108,"favorites":1517,"coin":6816,"likes":10454},{"aid":2,"mid":144900177,"score":300536,"view":652823,"reply":2661,"favorites":10268,"coin":470,"likes":4130},{"aid":3,"mid":32708462,"score":241845,"view":485737,"reply":969,"favorites":7347,"coin":1290,"likes":5542},{"aid":4,"mid":124799,"score":188953,"view":46594,"reply":595,"favorites":797,"coin":1771,"likes":6268}],"num":4,"note":"统计7日内新投稿的数据综合得分"}`
  15. // Convey("get data", t, WithCleanCache(func() {
  16. // s.setting.ShowRankNote = true
  17. // httpMock("GET", s.c.Article.RankHost+"/data/rank/article/all-7.json").Reply(200).JSON(data)
  18. // res, note, err := s.Ranks(context.TODO(), model.RankWeek, 1, "")
  19. // So(err, ShouldBeNil)
  20. // So(res, ShouldNotBeEmpty)
  21. // So(note, ShouldNotBeEmpty)
  22. // }))
  23. }