Documentation
¶
Overview ¶
Package testserver 提供标准 gRPC 与额外 HTTP 接口的测试环境。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPServer ¶ added in v1.3.3
type HTTPServer struct {
// contains filtered or unexported fields
}
HTTPServer 持有测试期间运行的标准 Server 和指向该服务的 HTTP Client。
func NewHTTP ¶ added in v1.3.3
func NewHTTP(t testing.TB, method string, path string, handler standard.HandlerFunc, opts ...standard.Option) *HTTPServer
NewHTTP 在本地回环地址启动额外 HTTP 接口,并在测试结束时自动释放资源。
func (*HTTPServer) Client ¶ added in v1.3.3
func (s *HTTPServer) Client() *http.Client
Client 返回连接到测试 Server 的 HTTP Client。
func (*HTTPServer) Close ¶ added in v1.3.3
func (s *HTTPServer) Close()
Close 释放 HTTP Client、Server 和 Listener,支持重复调用。
func (*HTTPServer) URL ¶ added in v1.3.3
func (s *HTTPServer) URL(path string) string
URL 返回测试 Server 上指定路径的完整 URL。
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server 持有测试期间运行的标准 Server 和指向该服务的 ClientConn。
func (*Server) Close ¶
func (s *Server) Close()
Close 释放 ClientConn、Server 和 bufconn Listener,支持重复调用。
func (*Server) Conn ¶
func (s *Server) Conn() *grpc.ClientConn
Conn 返回连接到测试 Server 的 gRPC ClientConn。
Click to show internal directories.
Click to hide internal directories.