validateRequest dispatches to provider-specific validators based on URL path and fails the test immediately if the request body is invalid.
(t *testing.T, call int, path string, body []byte)
| 265 | // validateRequest dispatches to provider-specific validators based on URL path |
| 266 | // and fails the test immediately if the request body is invalid. |
| 267 | func validateRequest(t *testing.T, call int, path string, body []byte) { |
| 268 | t.Helper() |
| 269 | |
| 270 | msgAndArgs := []any{fmt.Sprintf("request #%d validation failed\n\nBody:\n%s", call+1, body)} |
| 271 | switch { |
| 272 | case strings.Contains(path, "/chat/completions"): |
| 273 | validateOpenAIChatCompletion(t, body, msgAndArgs...) |
| 274 | case strings.Contains(path, "/responses"): |
| 275 | validateOpenAIResponses(t, body, msgAndArgs...) |
| 276 | case strings.Contains(path, "/messages"): |
| 277 | validateAnthropicMessages(t, body, msgAndArgs...) |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | // validateOpenAIChatCompletion validates that an OpenAI chat completion request |
| 282 | // has all required fields. |
no test coverage detected