-
Notifications
You must be signed in to change notification settings - Fork 0
xredismock
omeyang edited this page Sep 17, 2026
·
1 revision
稳定性:Internal · 覆盖率:87.0% · 源码:
pkg/testkit/xredismock
Redis Mock 客户端。集成测试用,不对生产使用。
- 测试需要 Redis 的 XKit 包(xsemaphore / xdlock / xcache / xlimit / xauth)
- 避免依赖外部 Redis
import "github.com/omeyang/xkit/pkg/testkit/xredismock"
func TestSomething(t *testing.T) {
mock := xredismock.New(t)
defer mock.Close()
client := mock.Client()
// 使用 client 测试
}| 名称 | 说明 |
|---|---|
Mock |
Mock 实例 |
New(t) |
启动,自动随 t.Cleanup 关闭 |
Client() |
获取 redis.UniversalClient |
- 包:使用 Redis 的所有 XKit 包
- ADR:0008 mock 放子包