httpstub

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 13 Imported by: 0

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL