- http2/adapter_test.go: 替换 pool reuse 测试,新增 header 转换边界测试 - 空头测试、特殊字符、多值头、长头名称 - http3/server_test.go: 替换 stats struct 测试,新增 Alt-Svc 头边界测试 - 端口边界值、禁用服务器、nil 配置 - http3/mock_test.go: 添加 QUIC listener mock 用于测试 - proxy/proxy_test.go: 添加 UpstreamTiming 边界测试 - 零值测试、部分标记测试 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
41 lines
816 B
Go
41 lines
816 B
Go
// Package http3 提供测试用的 Mock 实现
|
|
package http3
|
|
|
|
import (
|
|
"context"
|
|
"net"
|
|
|
|
"github.com/quic-go/quic-go"
|
|
)
|
|
|
|
// MockQUICListener 是 QUIC 监听器的 Mock 实现
|
|
type MockQUICListener struct {
|
|
AcceptFunc func(ctx context.Context) (*quic.Conn, error)
|
|
CloseFunc func() error
|
|
AddrFunc func() net.Addr
|
|
}
|
|
|
|
// Accept 接受连接
|
|
func (m *MockQUICListener) Accept(ctx context.Context) (*quic.Conn, error) {
|
|
if m.AcceptFunc != nil {
|
|
return m.AcceptFunc(ctx)
|
|
}
|
|
return nil, nil
|
|
}
|
|
|
|
// Close 关闭监听器
|
|
func (m *MockQUICListener) Close() error {
|
|
if m.CloseFunc != nil {
|
|
return m.CloseFunc()
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Addr 返回监听地址
|
|
func (m *MockQUICListener) Addr() net.Addr {
|
|
if m.AddrFunc != nil {
|
|
return m.AddrFunc()
|
|
}
|
|
return &net.UDPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 443}
|
|
}
|