From 584ca9170de922e8d0c684bbba3462976dee0b40 Mon Sep 17 00:00:00 2001 From: xfy Date: Thu, 16 Apr 2026 18:24:05 +0800 Subject: [PATCH] =?UTF-8?q?test(lua,security):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81=E9=94=99=E8=AF=AF=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E5=80=BC=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - api_socket_tcp_test.go: 使用空白标识符忽略非关键错误返回值 - auth_test.go: 使用空白标识符忽略不需要的 hash 返回值 Co-Authored-By: Claude Opus 4.6 --- internal/lua/api_socket_tcp_test.go | 5 ++--- internal/middleware/security/auth_test.go | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/lua/api_socket_tcp_test.go b/internal/lua/api_socket_tcp_test.go index 6f7be13..ce80933 100644 --- a/internal/lua/api_socket_tcp_test.go +++ b/internal/lua/api_socket_tcp_test.go @@ -804,13 +804,12 @@ func TestCheckTCPSocket_ArgError(t *testing.T) { // 传入非 userdata 应该 raise error L.Push(glua.LString("not a socket")) - err := L.PCall(0, 0, nil) + _ = L.PCall(0, 0, nil) // 这不会触发 checkTCPSocket,我们需要通过 Lua 脚本来测试 - err = L.DoString(` + _ = L.DoString(` local sock = ngx.socket.tcp() `) // 在没有注册 API 的情况下会失败 - _ = err } // TestLuaAPI_tcpSocketConnect_WithTimeout 测试 connect 带超时选项 diff --git a/internal/middleware/security/auth_test.go b/internal/middleware/security/auth_test.go index 264a332..d7d9b77 100644 --- a/internal/middleware/security/auth_test.go +++ b/internal/middleware/security/auth_test.go @@ -547,7 +547,7 @@ func TestHashPassword(t *testing.T) { t.Errorf("Expected argon2id hash, got %s", hash) } - hash, err = HashPassword(password, HashAlgorithm(99)) + _, err = HashPassword(password, HashAlgorithm(99)) if err == nil { t.Error("Expected error for unknown algorithm") }