style(go): 合并连续变量声明并明确规范约束
This commit is contained in:
1 parent
2492251a89
commit
5287321ca2
8 files changed
+42
-126
No files matched your search
@@ -17,16 +17,10 @@ import (
|
||||
// TestNativePipelineObservationPreservesData 验证 Pipeline 逐条对应记录,日志脱敏不修改执行参数和返回正文。
|
||||
func TestNativePipelineObservationPreservesData(t *testing.T) {
|
||||
var (
|
||||
client = redisserver.New(t, 3)
|
||||
)
|
||||
var (
|
||||
client = redisserver.New(t, 3)
|
||||
core, logs = observer.New(zap.InfoLevel)
|
||||
)
|
||||
var (
|
||||
ctx = context.Background()
|
||||
)
|
||||
var (
|
||||
value = `{"nested":{"token":"private-token"},"data":"kept"}`
|
||||
ctx = context.Background()
|
||||
value = `{"nested":{"token":"private-token"},"data":"kept"}`
|
||||
)
|
||||
client.AddHook(New(zap.New(core), "cache"))
|
||||
var (
|
||||
@@ -34,9 +28,7 @@ func TestNativePipelineObservationPreservesData(t *testing.T) {
|
||||
)
|
||||
pipeline.Set(ctx, "safe-key", value, 0)
|
||||
var (
|
||||
get = pipeline.Get(ctx, "safe-key")
|
||||
)
|
||||
var (
|
||||
get = pipeline.Get(ctx, "safe-key")
|
||||
missing = pipeline.Get(ctx, "missing-key")
|
||||
)
|
||||
if _, err := pipeline.Exec(ctx); !errors.Is(err, redis.Nil) {
|
||||
@@ -71,18 +63,10 @@ func TestNativePipelineObservationPreservesData(t *testing.T) {
|
||||
func TestHookObservesReturnedError(t *testing.T) {
|
||||
var (
|
||||
core, logs = observer.New(zap.InfoLevel)
|
||||
)
|
||||
var (
|
||||
hook = New(zap.New(core), "cache")
|
||||
)
|
||||
var (
|
||||
cmd = redis.NewStringCmd(context.Background(), "get", "safe-key")
|
||||
)
|
||||
var (
|
||||
calls int
|
||||
)
|
||||
var (
|
||||
process = hook.ProcessHook(func(context.Context, redis.Cmder) error { calls++; return context.Canceled })
|
||||
hook = New(zap.New(core), "cache")
|
||||
cmd = redis.NewStringCmd(context.Background(), "get", "safe-key")
|
||||
calls int
|
||||
process = hook.ProcessHook(func(context.Context, redis.Cmder) error { calls++; return context.Canceled })
|
||||
)
|
||||
if err := process(context.Background(), cmd); !errors.Is(err, context.Canceled) {
|
||||
t.Fatalf("error changed: %v", err)
|
||||
|
||||