vcr

package
v2.66.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BodyMatcherIgnore = []string{

	"organization",
	"organization_id",
	"project_id",
	"project",

	"name",
	"expires_at",
	"password",

	"mnq_project_id",
	"mnq_region",
	"mnq_nats_account_id",
	"mnq_nats_subject",
}

BodyMatcherIgnore contains the list of json body keys that should be ignored when matching requests with cassettes

View Source
var QueryMatcherIgnore = []string{
	"organization_id",
	"project_id",
	"start",
	"end",
}

QueryMatcherIgnore contains the list of query value that should be ignored when matching requests with cassettes

Functions

func CassetteMatcher

func CassetteMatcher(request *http.Request, cassette cassette.Request) bool

CassetteMatcher is a custom matcher that checks equivalence of a played request against a recorded one It compares method, path and query but will remove unwanted values from query

func NewHTTPRecorder

func NewHTTPRecorder(
	t *testing.T,
	pkgFolder string,
	update bool,
	realTransport http.RoundTripper,
	additionalHooks ...AdditionalHook,
) (*recorder.Recorder, error)

NewHTTPRecorder creates a new httpClient that records all HTTP requests in a cassette. This cassette is then replayed whenever tests are executed again. This means that once the requests are recorded in the cassette, no more real HTTP requests must be made to run the tests.

It is important to add a `defer cleanup()` so the given cassette files are correctly closed and saved after the requests.

Types

type AdditionalHook

type AdditionalHook struct {
	HookFunc recorder.HookFunc
	Kind     recorder.HookKind
}

Jump to

Keyboard shortcuts

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