Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
45 lines
1.3 KiB
Go
45 lines
1.3 KiB
Go
package modelgateway
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestGatewayBoundsJSONFallbackForStreamingResponse(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
const maxResponseBytes = 512
|
|
upstream := httptest.NewServer(http.HandlerFunc(func(writer http.ResponseWriter, _ *http.Request) {
|
|
writer.Header().Set("Content-Type", "application/json")
|
|
_, _ = io.WriteString(
|
|
writer,
|
|
fmt.Sprintf(
|
|
`{"id":"chat-oversized","model":"model-a","choices":[{"index":0,"message":{"role":"assistant","content":%q},"finish_reason":"stop"}]}`,
|
|
strings.Repeat("x", maxResponseBytes),
|
|
),
|
|
)
|
|
}))
|
|
defer upstream.Close()
|
|
|
|
gateway := newTestGateway(t, Config{MaxRequestBytes: maxResponseBytes})
|
|
endpoint := registerTestRoute(t, gateway, upstream.URL, "secret", "model-a", "workspace", "session")
|
|
response := postResponses(t, endpoint, `{"model":"model-a","input":"hello","stream":true}`, nil)
|
|
defer response.Body.Close()
|
|
|
|
if response.StatusCode != http.StatusBadGateway {
|
|
t.Fatalf(
|
|
"status = %d, want %d, body = %s",
|
|
response.StatusCode,
|
|
http.StatusBadGateway,
|
|
readBody(t, response.Body),
|
|
)
|
|
}
|
|
if body := readBody(t, response.Body); !strings.Contains(body, `"code":"upstream_error"`) {
|
|
t.Fatalf("body = %s, want upstream_error", body)
|
|
}
|
|
}
|