Documentation
¶
Overview ¶
Package vcr provides utilities for recording and replaying HTTP interactions in tests using go-vcr.
Index ¶
- func GetAPIKeyForVCR(t *testing.T) string
- func GetHTTPSClient(t *testing.T) *https.Client
- func NewHTTPClient(t *testing.T) *http.Client
- func NewVCRRecorder(t *testing.T, cassettePath string) (*recorder.Recorder, error)
- func WrapHTTPClient(t *testing.T, httpClient *http.Client) *http.Client
- type Mode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAPIKeyForVCR ¶ added in v0.1.0
GetAPIKeyForVCR returns an API key for VCR-enabled tests. In replay mode, returns a dummy key. In record/off modes, reads from BRAINTRUST_API_KEY env var.
func GetHTTPSClient ¶
GetHTTPSClient creates an HTTPS client for integration tests with VCR support. It wraps the HTTP client with VCR recording/replay based on VCR_MODE environment variable. The cassette name is automatically derived from t.Name(). In replay mode, a dummy API key is used. In record/off modes, BRAINTRUST_API_KEY is required.
func NewHTTPClient ¶
NewHTTPClient creates a new HTTP client with VCR support. If VCR_MODE=off, returns a standard HTTP client. The cassette name is automatically derived from t.Name().
func NewVCRRecorder ¶
NewVCRRecorder creates a new VCR recorder for the given cassette path. The recorder automatically scrubs sensitive headers before saving.
func WrapHTTPClient ¶
WrapHTTPClient wraps an existing http.Client with VCR recording/replay functionality. If VCR_MODE=off, returns the original client unchanged. The cassette name is automatically derived from t.Name(). Cassettes are stored in testdata/cassettes/<test-name>.yaml