feat: add a redis abstraction to support different versions of the redis sdk (#549)

This commit is contained in:
Ryo
2025-08-05 16:09:54 +08:00
committed by GitHub
parent d4d0ba6b9a
commit ab0ce50df5
11 changed files with 316 additions and 31 deletions

View File

@@ -25,7 +25,6 @@ import (
"github.com/DATA-DOG/go-sqlmock"
"github.com/alicebob/miniredis/v2"
"github.com/redis/go-redis/v9"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
"gorm.io/driver/mysql"
@@ -33,12 +32,14 @@ import (
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/repo/dal/query"
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
"github.com/coze-dev/coze-studio/backend/infra/impl/cache/redis"
)
type ExecuteHistoryStoreSuite struct {
suite.Suite
db *gorm.DB
redis *redis.Client
redis cache.Cmdable
mock sqlmock.Sqlmock
store *executeHistoryStoreImpl
}
@@ -47,7 +48,7 @@ func (s *ExecuteHistoryStoreSuite) SetupTest() {
var err error
mr, err := miniredis.Run()
assert.NoError(s.T(), err)
s.redis = redis.NewClient(&redis.Options{Addr: mr.Addr()})
s.redis = redis.NewWithAddrAndPassword(mr.Addr(), "")
mockDB, mock, err := sqlmock.New()
assert.NoError(s.T(), err)