Documentation
¶
Overview ¶
Package httpstub provides functionality for stubbing an HTTP server and spying on requests in testscript tests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cmd ¶
func Cmd(cmdName string) func(*testscript.TestScript, bool, []string)
Cmd returns a github.com/rogpeppe/go-internal/testscript command for registering HTTP stubs and dumping corresponding HTTP requests to files.
The stub server must be initialized with InitServer in the testscript.Params.Setup.
Types ¶
type Server ¶
type Server struct {
Addr string // Server address (e.g. 127.0.0.1:8080)
// contains filtered or unexported fields
}
Server represents an httptest.Server that can dump requests and respond with stubs provided via testscript command.
func InitServer ¶
func InitServer(env *testscript.Env, mutateDump func([]byte) []byte) *Server
InitServer initializes a Server in the testscript environment.
Click to show internal directories.
Click to hide internal directories.