From e3a0b013c19d61838317c8d0767461f8fcc112b1 Mon Sep 17 00:00:00 2001 From: Benson Wong Date: Wed, 14 May 2025 19:50:01 -0700 Subject: [PATCH] add content length test for #131 --- proxy/proxymanager_test.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/proxy/proxymanager_test.go b/proxy/proxymanager_test.go index 0c12b7b..32a007a 100644 --- a/proxy/proxymanager_test.go +++ b/proxy/proxymanager_test.go @@ -14,6 +14,7 @@ import ( "time" "github.com/stretchr/testify/assert" + "github.com/tidwall/gjson" ) func TestProxyManager_SwapProcessCorrectly(t *testing.T) { @@ -448,7 +449,6 @@ func TestProxyManager_AudioTranscriptionHandler(t *testing.T) { // Test useModelName in configuration sends overrides what is sent to upstream func TestProxyManager_UseModelName(t *testing.T) { upstreamModelName := "upstreamModel" - modelConfig := getTestSimpleResponderConfig(upstreamModelName) modelConfig.UseModelName = upstreamModelName @@ -473,6 +473,12 @@ func TestProxyManager_UseModelName(t *testing.T) { proxy.ServeHTTP(w, req) assert.Equal(t, http.StatusOK, w.Code) assert.Contains(t, w.Body.String(), upstreamModelName) + + // make sure the content length was set correctly + // simple-responder will return the content length it got in the response + body := w.Body.Bytes() + contentLength := int(gjson.GetBytes(body, "h_content_length").Int()) + assert.Equal(t, len(fmt.Sprintf(`{"model":"%s"}`, upstreamModelName)), contentLength) }) t.Run("useModelName over rides requested model: /v1/audio/transcriptions", func(t *testing.T) {