vcr

package
v2.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CassetteFileExists

func CassetteFileExists(cassetteName string) (bool, error)

func CassetteFileName

func CassetteFileName(cassetteName string) string

func EnsureCassetteFileExists

func EnsureCassetteFileExists(cassetteName string) error

Types

type FakeRoundTripper

type FakeRoundTripper struct {
	// contains filtered or unexported fields
}

FakeRoundTripper is a fake implementation of http.RoundTripper used in testing.

func NewFakeRoundTripper

func NewFakeRoundTripper() *FakeRoundTripper

func (*FakeRoundTripper) AddError

func (fake *FakeRoundTripper) AddError(request *http.Request, err error)

AddError adds an error to the fake round tripper.

func (*FakeRoundTripper) AddResponse

func (fake *FakeRoundTripper) AddResponse(request *http.Request, response *http.Response)

AddResponse adds a response to the fake round tripper.

func (*FakeRoundTripper) RoundTrip

func (fake *FakeRoundTripper) RoundTrip(request *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper.

type Interface

type Interface interface {
	// Cfg returns the available configuration for the test
	Cfg() config.Values

	// Creds returns Azure credentials when running for real
	Creds() azcore.TokenCredential

	// IDs returns the available Azure resource IDs for the test
	IDs() creds.AzureIDs

	// AddLiteralRedaction adds literal redaction value to redactor
	AddLiteralRedaction(redactionValue, replacementValue string)

	// AddRegexpRedaction adds regular expression redaction value to redactor
	AddRegexpRedaction(pattern, replacementValue string)

	// Stop recording
	Stop() error

	// IsReplaying returns true if we're replaying a recorded test, false if we're recording a new test
	IsReplaying() bool

	// CreateClient creates an HTTP client configured to record or replay HTTP requests.
	// t is a reference to the test currently executing.
	CreateClient(t *testing.T) *http.Client
}

Interface is a lightweight interface that allows us to swap out implementations of Go-VCR as required.

func NewTestPassthroughRecorder

func NewTestPassthroughRecorder(cfg config.Values) (Interface, error)

NewTestPassthroughRecorder returns an instance of testRecorder that does not record or replay HTTP requests,

type Redactor added in v2.9.0

type Redactor struct {
	// contains filtered or unexported fields
}

func NewRedactor added in v2.9.0

func NewRedactor(azureIDs creds.AzureIDs) *Redactor

func (*Redactor) AddLiteralRedaction added in v2.9.0

func (r *Redactor) AddLiteralRedaction(redactionValue string, replacementValue string)

func (*Redactor) AddRegexRedaction added in v2.9.0

func (r *Redactor) AddRegexRedaction(regex string, replacementValue string)

func (*Redactor) HideRecordingData added in v2.9.0

func (r *Redactor) HideRecordingData(s string) string

func (*Redactor) HideURLData added in v2.9.0

func (r *Redactor) HideURLData(s string) string

func (*Redactor) RedactRequestHeaders added in v2.9.0

func (r *Redactor) RedactRequestHeaders(headers http.Header)

func (*Redactor) RedactResponseHeaders added in v2.9.0

func (r *Redactor) RedactResponseHeaders(headers http.Header)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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