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 16f8af1
Show file tree
Hide file tree
Showing 7 changed files with 1,107 additions and 5 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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ require (
golang.org/x/sync v0.6.0
golang.org/x/time v0.5.0
google.golang.org/api v0.160.0
google.golang.org/protobuf v1.32.0
google.golang.org/protobuf v1.33.0
gopkg.in/dnaeon/go-vcr.v3 v3.2.0
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.27.11
Expand Down
1 change: 1 addition & 0 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4096998150677633605
Loading

0 comments on commit 16f8af1

Please sign in to comment.