MCPcopy Create free account
hub / github.com/coder/coder / TestPassthroughRoutesForProviders

Function TestPassthroughRoutesForProviders

aibridge/bridge_test.go:121–211  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

119}
120
121func TestPassthroughRoutesForProviders(t *testing.T) {
122 t.Parallel()
123
124 upstreamRespBody := "upstream response"
125 tests := []struct {
126 name string
127 baseURLPath string
128 requestPath string
129 provider func(string) provider.Provider
130 expectPath string
131 }{
132 {
133 name: "openAI_no_base_path",
134 requestPath: "/openai/v1/conversations",
135 provider: func(baseURL string) provider.Provider {
136 return aibridge.NewOpenAIProvider(config.OpenAI{BaseURL: baseURL})
137 },
138 expectPath: "/conversations",
139 },
140 {
141 name: "openAI_with_base_path",
142 baseURLPath: "/v1",
143 requestPath: "/openai/v1/conversations",
144 provider: func(baseURL string) provider.Provider {
145 return aibridge.NewOpenAIProvider(config.OpenAI{BaseURL: baseURL})
146 },
147 expectPath: "/v1/conversations",
148 },
149 {
150 name: "anthropic_no_base_path",
151 requestPath: "/anthropic/v1/models",
152 provider: func(baseURL string) provider.Provider {
153 return aibridge.NewAnthropicProvider(config.Anthropic{BaseURL: baseURL}, nil)
154 },
155 expectPath: "/v1/models",
156 },
157 {
158 name: "anthropic_with_base_path",
159 baseURLPath: "/v1",
160 requestPath: "/anthropic/v1/models",
161 provider: func(baseURL string) provider.Provider {
162 return aibridge.NewAnthropicProvider(config.Anthropic{BaseURL: baseURL}, nil)
163 },
164 expectPath: "/v1/v1/models",
165 },
166 {
167 name: "copilot_no_base_path",
168 requestPath: "/copilot/models",
169 provider: func(baseURL string) provider.Provider {
170 return aibridge.NewCopilotProvider(config.Copilot{BaseURL: baseURL})
171 },
172 expectPath: "/models",
173 },
174 {
175 name: "copilot_with_base_path",
176 baseURLPath: "/v1",
177 requestPath: "/copilot/models",
178 provider: func(baseURL string) provider.Provider {

Callers

nothing calls this directly

Calls 14

ServeHTTPMethod · 0.95
NewOpenAIProviderFunction · 0.92
NewAnthropicProviderFunction · 0.92
NewCopilotProviderFunction · 0.92
NewRequestBridgeFunction · 0.92
providerMethod · 0.80
RunMethod · 0.65
WriteMethod · 0.65
CleanupMethod · 0.65
ContextMethod · 0.65
EqualMethod · 0.45
WriteHeaderMethod · 0.45

Tested by

no test coverage detected