test(lua,security): 优化测试代码错误返回值处理

- api_socket_tcp_test.go: 使用空白标识符忽略非关键错误返回值
- auth_test.go: 使用空白标识符忽略不需要的 hash 返回值

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
xfy 2026-04-16 18:24:05 +08:00
parent 9d95aecd6f
commit 584ca9170d
2 changed files with 3 additions and 4 deletions

View File

@ -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 带超时选项

View File

@ -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")
}