startReplayProxy starts a VCR proxy in replay-only mode against the cassette named after the current test, and returns a RuntimeConfig pointed at it. Recordings live in testdata/cassettes/ .yaml.
(t *testing.T)
| 102 | // named after the current test, and returns a RuntimeConfig pointed at it. |
| 103 | // Recordings live in testdata/cassettes/<TestName>.yaml. |
| 104 | func startReplayProxy(t *testing.T) *config.RuntimeConfig { |
| 105 | t.Helper() |
| 106 | |
| 107 | cassettePath := filepath.Join("testdata", "cassettes", t.Name()) |
| 108 | |
| 109 | matcher := fake.DefaultMatcher(func(err error) { require.NoError(t, err) }) |
| 110 | |
| 111 | proxyURL, cleanup, err := fake.StartProxyWithOptions( |
| 112 | t.Context(), |
| 113 | cassettePath, |
| 114 | recorder.ModeReplayOnly, |
| 115 | matcher, |
| 116 | func(string, *http.Request) {}, // no API keys needed for replay |
| 117 | nil, |
| 118 | ) |
| 119 | require.NoError(t, err) |
| 120 | t.Cleanup(func() { require.NoError(t, cleanup()) }) |
| 121 | |
| 122 | return &config.RuntimeConfig{ |
| 123 | Config: config.Config{ModelsGateway: proxyURL}, |
| 124 | EnvProviderForTests: &mapEnvProvider{ |
| 125 | environment.DockerDesktopTokenEnv: "DUMMY", |
| 126 | }, |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | // mapEnvProvider is a static environment.Provider for tests. |
| 131 | type mapEnvProvider map[string]string |
no test coverage detected