stat_test.go 884 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package service
  2. import (
  3. "context"
  4. "testing"
  5. artmdl "go-common/app/interface/openplatform/article/model"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. func Test_Stat(t *testing.T) {
  9. var (
  10. err error
  11. c = context.TODO()
  12. statCnt = int64(5)
  13. stat = &artmdl.StatMsg{
  14. Aid: 88,
  15. View: &statCnt,
  16. Favorite: &statCnt,
  17. Like: &statCnt,
  18. Dislike: &statCnt,
  19. Reply: &statCnt,
  20. Share: &statCnt,
  21. }
  22. )
  23. Convey("updateCache", t, WithoutProcService(func(s *Service) {
  24. err = s.updateCache(c, stat, 0)
  25. So(err, ShouldBeNil)
  26. }))
  27. Convey("updateDB", t, WithoutProcService(func(s *Service) {
  28. err = s.updateDB(c, stat, 0)
  29. So(err, ShouldBeNil)
  30. }))
  31. Convey("select Stat", t, WithoutProcService(func(s *Service) {
  32. var stat *artmdl.StatMsg
  33. stat, err = s.dao.Stat(c, 1)
  34. So(err, ShouldBeNil)
  35. So(stat, ShouldNotBeEmpty)
  36. }))
  37. }