MCPcopy
hub / github.com/QuantumNous/new-api / TestRelayErrorHandlerKeepsOpenAIErrorMessage

Function TestRelayErrorHandlerKeepsOpenAIErrorMessage

service/error_test.go:111–123  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

109}
110
111func TestRelayErrorHandlerKeepsOpenAIErrorMessage(t *testing.T) {
112 message := strings.Repeat("d", common.LocalLogContentLimit+256)
113 body := `{"error":{"message":"` + message + `","type":"server_error","code":"server_error"}}`
114 resp := &http.Response{
115 StatusCode: http.StatusInternalServerError,
116 Body: io.NopCloser(strings.NewReader(body)),
117 }
118
119 newAPIError := RelayErrorHandler(context.Background(), resp, false)
120
121 require.NotNil(t, newAPIError)
122 require.Equal(t, message, newAPIError.Error())
123}
124
125func TestRelayErrorHandlerKeepsInvalidJSONBodyInDebugLog(t *testing.T) {
126 withDebugEnabled(t, true)

Callers

nothing calls this directly

Calls 3

RelayErrorHandlerFunction · 0.85
EqualMethod · 0.80
ErrorMethod · 0.45

Tested by

no test coverage detected