Skip to content

Commit

Permalink
replay
Browse files Browse the repository at this point in the history
  • Loading branch information
gemmahou committed Mar 19, 2024
1 parent 114fc17 commit b0651bd
Show file tree
Hide file tree
Showing 5 changed files with 1,091 additions and 4 deletions.
12 changes: 11 additions & 1 deletion config/tests/samples/create/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,16 @@ func NewHarness(ctx context.Context, t *testing.T) *Harness {
}

if targetGCP := os.Getenv("E2E_GCP_TARGET"); targetGCP == "vcr" {
// Initialize VCR for TF requests
input := os.Getenv("VCR_MODE")
var VCRMode recorder.Mode
if input == "Recording" {
VCRMode = recorder.ModeRecordOnly
} else if input == "Replaying" {
VCRMode = recorder.ModeReplayOnly
} else {
t.Fatalf("[VCR] Input mode is not supported.")
}
transport_tpg.DefaultHTTPClientTransformer = func(ctx context.Context, inner *http.Client) *http.Client {
ret := inner
if t := ctx.Value(httpRoundTripperKey); t != nil {
Expand All @@ -321,7 +331,7 @@ func NewHarness(ctx context.Context, t *testing.T) *Harness {
testName := strings.ReplaceAll(t.Name(), "/", "_")
opts := &recorder.Options{
CassetteName: filepath.Join(dir, testName),
Mode: recorder.ModeRecordOnly,
Mode: VCRMode,
RealTransport: ret.Transport,
}
r, err := recorder.NewWithOptions(opts)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4096998150677633605
Loading

0 comments on commit b0651bd

Please sign in to comment.