httptest

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package httptest provides utilities for HTTP testing. It includes helpers for the VCR library we use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTransportRecorder

func NewTransportRecorder(
	t testing.TB,
	name string,
	opts TransportRecorderOptions,
) *recorder.Recorder

NewTransportRecorder builds a new HTTP request recorder/replayer that will write fixtures to testdata/fixtures/<name>.

The returned Recorder will be in recording mode if the -update flag is set, and in replay mode otherwise.

Types

type TransportRecorderOptions

type TransportRecorderOptions struct {
	// Update specifies whether the Recorder should update fixtures.
	//
	// If unset, we will assume false.
	Update *bool

	// WrapRealTransport wraps the real HTTP transport
	// with the given function.
	//
	// This is called only in update mode.
	WrapRealTransport func(
		t testing.TB,
		transport http.RoundTripper,
	) http.RoundTripper

	Matcher func(*http.Request, cassette.Request) bool
}

TransportRecorderOptions contains options for creating a new [TransportRecorder].

Jump to

Keyboard shortcuts

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