redis_like_test.go 623 B

123456789101112131415161718192021222324252627282930
  1. package dao
  2. import (
  3. "context"
  4. "testing"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. func Test_MaxLikeCache(t *testing.T) {
  8. var (
  9. aid = int64(100)
  10. value = int64(200)
  11. err error
  12. )
  13. Convey("add cache", t, WithCleanCache(func() {
  14. err = d.SetMaxLikeCache(context.TODO(), aid, value)
  15. So(err, ShouldBeNil)
  16. Convey("get cache", func() {
  17. res, err := d.MaxLikeCache(context.TODO(), aid)
  18. So(err, ShouldBeNil)
  19. So(res, ShouldEqual, value)
  20. })
  21. Convey("expire cache", func() {
  22. res, err := d.ExpireMaxLikeCache(context.TODO(), aid)
  23. So(err, ShouldBeNil)
  24. So(res, ShouldEqual, true)
  25. })
  26. }))
  27. }