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:
parent
9d95aecd6f
commit
584ca9170d
@ -804,13 +804,12 @@ func TestCheckTCPSocket_ArgError(t *testing.T) {
|
|||||||
|
|
||||||
// 传入非 userdata 应该 raise error
|
// 传入非 userdata 应该 raise error
|
||||||
L.Push(glua.LString("not a socket"))
|
L.Push(glua.LString("not a socket"))
|
||||||
err := L.PCall(0, 0, nil)
|
_ = L.PCall(0, 0, nil)
|
||||||
// 这不会触发 checkTCPSocket,我们需要通过 Lua 脚本来测试
|
// 这不会触发 checkTCPSocket,我们需要通过 Lua 脚本来测试
|
||||||
err = L.DoString(`
|
_ = L.DoString(`
|
||||||
local sock = ngx.socket.tcp()
|
local sock = ngx.socket.tcp()
|
||||||
`)
|
`)
|
||||||
// 在没有注册 API 的情况下会失败
|
// 在没有注册 API 的情况下会失败
|
||||||
_ = err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestLuaAPI_tcpSocketConnect_WithTimeout 测试 connect 带超时选项
|
// TestLuaAPI_tcpSocketConnect_WithTimeout 测试 connect 带超时选项
|
||||||
|
|||||||
@ -547,7 +547,7 @@ func TestHashPassword(t *testing.T) {
|
|||||||
t.Errorf("Expected argon2id hash, got %s", hash)
|
t.Errorf("Expected argon2id hash, got %s", hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
hash, err = HashPassword(password, HashAlgorithm(99))
|
_, err = HashPassword(password, HashAlgorithm(99))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Error("Expected error for unknown algorithm")
|
t.Error("Expected error for unknown algorithm")
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user