bangumi_feed_test.go 798 B

1234567891011121314151617181920212223242526272829
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. "time"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. func Test_BangumiFeed(t *testing.T) {
  9. Convey("bangumi feed", t, WithService(t, func(svf *Service) {
  10. res, err := svf.BangumiFeed(context.TODO(), _bangumiMid, 1, 2, _ip)
  11. So(err, ShouldBeNil)
  12. So(res, ShouldNotBeEmpty)
  13. Convey("return feed for page 2", func() {
  14. time.Sleep(time.Millisecond * 300) // wait cache ready
  15. res, err := svf.BangumiFeed(context.TODO(), _bangumiMid, 2, 2, _ip)
  16. So(err, ShouldBeNil)
  17. So(res, ShouldNotBeEmpty)
  18. })
  19. Convey("bangumi feed cache", func() {
  20. time.Sleep(time.Millisecond * 300) // wait cache ready
  21. res, err := svf.bangumiFeedCache(context.TODO(), _bangumiMid, 3, 2, _ip)
  22. So(err, ShouldBeNil)
  23. So(res, ShouldNotBeEmpty)
  24. })
  25. }))
  26. }