(t *testing.T)
| 588 | } |
| 589 | |
| 590 | func TestTraceOpenAIErr(t *testing.T) { |
| 591 | t.Parallel() |
| 592 | |
| 593 | cases := []struct { |
| 594 | name string |
| 595 | fixture []byte |
| 596 | streaming bool |
| 597 | allowOverflow bool |
| 598 | path string |
| 599 | |
| 600 | expect []expectTrace |
| 601 | expectCode int |
| 602 | }{ |
| 603 | { |
| 604 | name: "trace_openai_chat_streaming_error", |
| 605 | fixture: fixtures.OaiChatMidStreamError, |
| 606 | streaming: true, |
| 607 | path: pathOpenAIChatCompletions, |
| 608 | expectCode: http.StatusOK, |
| 609 | expect: []expectTrace{ |
| 610 | {"Intercept", 1, codes.Error}, |
| 611 | {"Intercept.CreateInterceptor", 1, codes.Unset}, |
| 612 | {"Intercept.RecordInterception", 1, codes.Unset}, |
| 613 | {"Intercept.ProcessRequest", 1, codes.Error}, |
| 614 | {"Intercept.RecordInterceptionEnded", 1, codes.Unset}, |
| 615 | {"Intercept.RecordPromptUsage", 1, codes.Unset}, |
| 616 | {"Intercept.ProcessRequest.Upstream", 1, codes.Unset}, |
| 617 | }, |
| 618 | }, |
| 619 | { |
| 620 | name: "trace_openai_chat_blocking_error", |
| 621 | fixture: fixtures.OaiChatNonStreamError, |
| 622 | streaming: false, |
| 623 | path: pathOpenAIChatCompletions, |
| 624 | expectCode: http.StatusBadRequest, |
| 625 | expect: []expectTrace{ |
| 626 | {"Intercept", 1, codes.Error}, |
| 627 | {"Intercept.CreateInterceptor", 1, codes.Unset}, |
| 628 | {"Intercept.RecordInterception", 1, codes.Unset}, |
| 629 | {"Intercept.ProcessRequest", 1, codes.Error}, |
| 630 | {"Intercept.RecordInterceptionEnded", 1, codes.Unset}, |
| 631 | {"Intercept.ProcessRequest.Upstream", 1, codes.Error}, |
| 632 | }, |
| 633 | }, |
| 634 | { |
| 635 | name: "trace_openai_responses_streaming_error", |
| 636 | streaming: true, |
| 637 | fixture: fixtures.OaiResponsesStreamingWrongResponseFormat, |
| 638 | path: pathOpenAIResponses, |
| 639 | expectCode: http.StatusOK, |
| 640 | expect: []expectTrace{ |
| 641 | {"Intercept", 1, codes.Error}, |
| 642 | {"Intercept.CreateInterceptor", 1, codes.Unset}, |
| 643 | {"Intercept.RecordInterception", 1, codes.Unset}, |
| 644 | {"Intercept.ProcessRequest", 1, codes.Error}, |
| 645 | {"Intercept.RecordInterceptionEnded", 1, codes.Unset}, |
| 646 | {"Intercept.RecordPromptUsage", 1, codes.Unset}, |
| 647 | {"Intercept.ProcessRequest.Upstream", 1, codes.Unset}, |
nothing calls this directly
no test coverage detected