feed_test.go 939 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. "go-common/app/interface/main/web-feed/conf"
  6. "go-common/app/interface/main/web-feed/model"
  7. . "github.com/smartystreets/goconvey/convey"
  8. )
  9. func initConf(t *testing.T) {
  10. if err := conf.Init(); err != nil {
  11. t.Errorf("conf.Init() error(%v)", err)
  12. t.FailNow()
  13. }
  14. }
  15. func TestFeed(t *testing.T) {
  16. Convey("feed", t, func() {
  17. var (
  18. mid int64 = 27515256
  19. pn = 1
  20. ps = 20
  21. c = context.TODO()
  22. res []*model.Feed
  23. err error
  24. )
  25. initConf(t)
  26. svr := New(conf.Conf)
  27. if res, err = svr.Feed(c, mid, pn, ps); err != nil {
  28. t.Error(err)
  29. }
  30. t.Logf("result length:%d", len(res))
  31. })
  32. }
  33. func TestUnreadCount(t *testing.T) {
  34. var (
  35. mid int64 = 27515256
  36. c = context.TODO()
  37. count int
  38. err error
  39. )
  40. initConf(t)
  41. svr := New(conf.Conf)
  42. if count, err = svr.UnreadCount(c, mid); err != nil {
  43. t.Error(err)
  44. }
  45. t.Logf("count:%d", count)
  46. }