localcache_test.go 896 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package dao
  2. import (
  3. "context"
  4. "go-common/app/service/main/relation/model"
  5. "testing"
  6. "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDaoloadStat(t *testing.T) {
  9. var (
  10. ctx = context.Background()
  11. mid = int64(1)
  12. stat = &model.Stat{
  13. Mid: 1,
  14. Follower: 1,
  15. Following: 1,
  16. Black: 1,
  17. Whisper: 1,
  18. }
  19. )
  20. d.SetStatCache(ctx, mid, stat)
  21. d.storeStat(mid, stat)
  22. convey.Convey("loadStat", t, func(cv convey.C) {
  23. d.storeStat(mid, stat)
  24. cv.Convey("No return values", func(cv convey.C) {
  25. })
  26. s1, err := d.loadStat(ctx, mid)
  27. cv.Convey("loadStat", func(cv convey.C) {
  28. cv.So(err, convey.ShouldBeNil)
  29. cv.So(s1, convey.ShouldNotBeNil)
  30. })
  31. p1, p2, err := d.StatsCache(ctx, []int64{1})
  32. cv.Convey("StatsCache", func(cv convey.C) {
  33. cv.So(err, convey.ShouldBeNil)
  34. cv.So(p2, convey.ShouldNotBeNil)
  35. cv.So(p1, convey.ShouldNotBeNil)
  36. })
  37. })
  38. }