hotspots_test.go 1000 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package service
  2. import (
  3. "testing"
  4. "time"
  5. "go-common/app/interface/openplatform/article/model"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. func Test_Hotsports(t *testing.T) {
  9. _hotspotArtTime = time.Hour * 24 * 365 * 10
  10. Convey("gen data", t, func() {
  11. err := s.UpdateHotspots(true)
  12. So(err, ShouldBeNil)
  13. res, err := s.dao.CacheHotspots(c)
  14. So(err, ShouldBeNil)
  15. So(res, ShouldNotBeEmpty)
  16. hot := res[0]
  17. Convey("add art", func() {
  18. err = s.AddCacheHotspotArt(c, &model.SearchArt{StatsView: 100, ID: 100, Tags: []string{hot.Tag}, PublishTime: time.Now().Unix()})
  19. So(err, ShouldBeNil)
  20. var hot2 *model.Hotspot
  21. hot2, err = s.dao.CacheHotspot(c, hot.ID)
  22. So(hot2.Stats.Read-hot.Stats.Read, ShouldEqual, 100)
  23. })
  24. Convey("get art", func() {
  25. var arts []*model.MetaWithLike
  26. var hotspot *model.Hotspot
  27. hotspot, arts, err = s.HotspotArts(c, hot.ID, 1, 100, nil, 0, 0)
  28. So(err, ShouldBeNil)
  29. So(arts, ShouldNotBeEmpty)
  30. So(hotspot, ShouldNotBeEmpty)
  31. })
  32. })
  33. }