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

Function TestTraceOpenAIErr

aibridge/internal/integrationtest/trace_internal_test.go:590–749  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

588}
589
590func 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},

Callers

nothing calls this directly

Calls 15

ParseFunction · 0.92
setupTracerFunction · 0.85
newFixtureResponseFunction · 0.85
newBridgeTestServerFunction · 0.85
withTracerFunction · 0.85
verifyTracesFunction · 0.85
RecordedInterceptionsMethod · 0.80
newMockUpstreamFunction · 0.70
RunMethod · 0.65
ContextMethod · 0.65
CleanupMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected