|
|
|
@@ -97,6 +97,24 @@ func TestStreamScannerHandler_EmptyBody(t *testing.T) { |
|
|
|
assert.False(t, called.Load(), "handler should not be called for empty body") |
|
|
|
} |
|
|
|
|
|
|
|
func TestStreamScannerHandler_NonPositiveStreamingTimeoutDoesNotPanic(t *testing.T) { |
|
|
|
oldTimeout := constant.StreamingTimeout |
|
|
|
constant.StreamingTimeout = 0 |
|
|
|
t.Cleanup(func() { |
|
|
|
constant.StreamingTimeout = oldTimeout |
|
|
|
}) |
|
|
|
|
|
|
|
recorder := httptest.NewRecorder() |
|
|
|
c, _ := gin.CreateTestContext(recorder) |
|
|
|
c.Request = httptest.NewRequest(http.MethodPost, "/v1/chat/completions", nil) |
|
|
|
resp := &http.Response{Body: io.NopCloser(strings.NewReader(""))} |
|
|
|
info := &relaycommon.RelayInfo{ChannelMeta: &relaycommon.ChannelMeta{}} |
|
|
|
|
|
|
|
require.NotPanics(t, func() { |
|
|
|
StreamScannerHandler(c, resp, info, func(data string) bool { return true }) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
func TestStreamScannerHandler_1000Chunks(t *testing.T) { |
|
|
|
t.Parallel() |
|
|
|
|
|
|
|
|