newChatTestOptions builds coderdtest options for chat runtime tests. Unless a test sets ChatProviderAPIKeys explicitly, it installs a fake OpenAI-compatible provider before coderd starts so background chat work stays local, and the fake server outlives chatd during cleanup.
( t testing.TB, values *codersdk.DeploymentValues, overrides ...func(*coderdtest.Options), )
| 69 | // OpenAI-compatible provider before coderd starts so background chat work stays |
| 70 | // local, and the fake server outlives chatd during cleanup. |
| 71 | func newChatTestOptions( |
| 72 | t testing.TB, |
| 73 | values *codersdk.DeploymentValues, |
| 74 | overrides ...func(*coderdtest.Options), |
| 75 | ) *coderdtest.Options { |
| 76 | t.Helper() |
| 77 | |
| 78 | opts := &coderdtest.Options{ |
| 79 | DeploymentValues: values, |
| 80 | } |
| 81 | for _, override := range overrides { |
| 82 | override(opts) |
| 83 | } |
| 84 | if opts.ChatProviderAPIKeys == nil { |
| 85 | providerKeys := coderdtest.FakeOpenAICompatProviderAPIKeys(t) |
| 86 | opts.ChatProviderAPIKeys = &providerKeys |
| 87 | } |
| 88 | return opts |
| 89 | } |
| 90 | |
| 91 | func newChatClient(t testing.TB, overrides ...func(*coderdtest.Options)) *codersdk.ExperimentalClient { |
| 92 | t.Helper() |
no test coverage detected