fix: 消除合并后的变量遮蔽以通过检查

This commit is contained in:
Nixevol
2026-09-30 12:12:13 +08:00
parent 7b209ce3d6
commit 4059a1576b
4 changed files with 11 additions and 9 deletions
+4 -4
View File
@@ -200,8 +200,8 @@ func runServe(ctx context.Context, cfg config.Config) error {
if _, found := brk.ConnInfoOf(endpointID); !found {
return false, nil
}
if err := sess.Disable(kickCtx, endpointID); err != nil {
return false, err
if disableErr := sess.Disable(kickCtx, endpointID); disableErr != nil {
return false, disableErr
}
return true, nil
},
@@ -209,8 +209,8 @@ func runServe(ctx context.Context, cfg config.Config) error {
if _, found := brk.ConnInfoOf(endpointID); !found {
return false, nil
}
if err := sess.Deleted(kickCtx, endpointID); err != nil {
return false, err
if deleteErr := sess.Deleted(kickCtx, endpointID); deleteErr != nil {
return false, deleteErr
}
return true, nil
},
+2 -2
View File
@@ -304,9 +304,9 @@ func TestAdminLockDoesNotBlockAuthedSession(t *testing.T) {
for i := 0; i < 10; i++ {
bad := &http.Client{}
res := postJSON(t, bad, base+"/api/admin/login",
res = postJSON(t, bad, base+"/api/admin/login",
`{"username":"admin","password":"wrong-password!!"}`, nil)
env := decodeEnv(t, res)
env = decodeEnv(t, res)
if i < 9 {
if res.StatusCode != 401 {
t.Fatalf("fail %d: want 401 got %d %+v", i, res.StatusCode, env)
+1 -1
View File
@@ -371,7 +371,7 @@ func TestRegisterTrustedProxyClientIPLock(t *testing.T) {
locks.Clear(auth.LockKey{Kind: auth.LockRegisterIP, IP: "198.51.100.7"})
locks.Clear(auth.LockKey{Kind: auth.LockRegisterIP, IP: "203.0.113.50"})
for i := 0; i < 10; i++ {
code, resp := post("203.0.113.50:4433", "198.51.100.7", wrong)
code, resp = post("203.0.113.50:4433", "198.51.100.7", wrong)
if code != http.StatusForbidden || resp.Error == nil || resp.Error.Code != protocol.CodeRegistrationCodeInvalid {
t.Fatalf("untrusted fail #%d: status=%d resp=%+v", i+1, code, resp)
}
+4 -2
View File
@@ -31,7 +31,8 @@ VALUES ('alice', 'm1', 'endpoint', 'bob', 100, 1, 0, 0, 'dispatched', '', 1, 'te
t.Fatal(err)
}
var seq int64
if err := db.Write.QueryRowContext(ctx, `SELECT seq FROM messages WHERE id='m1'`).Scan(&seq); err != nil {
err = db.Write.QueryRowContext(ctx, `SELECT seq FROM messages WHERE id='m1'`).Scan(&seq)
if err != nil {
t.Fatal(err)
}
_, err = db.Write.ExecContext(ctx, `
@@ -48,7 +49,8 @@ VALUES ('alice', 'm2', 'endpoint', 'bob', 999999, 0, 0, 0, 'scheduled', '', 1, '
}
reg := New()
if err := SampleStoreGauges(ctx, reg, db.Read); err != nil {
err = SampleStoreGauges(ctx, reg, db.Read)
if err != nil {
t.Fatal(err)
}
SampleQueues(reg, 3, 1)