X-Git-Url: https://git.giacomolli.uk/onechat/blobdiff_plain/c781f79f3c8cb9a7577ee1574d196988da2719b3..9346d20fe4297dce1aa16171749a7ef3e41ce7bd:/model_test.go?ds=inline diff --git a/model_test.go b/model_test.go index 3ea82d4..4045e9d 100644 --- a/model_test.go +++ b/model_test.go @@ -65,12 +65,12 @@ func TestClientSendsTheSessionHeaderToChatGPT(t *testing.T) { want string }{ { - name: "ChatGPT backend", + name: "sends the session header to ChatGPT", auth: auth, want: "agent-key", }, { - name: "OpenAI API", + name: "omits the session header for the API", auth: ModelAPIKey(modelTestKey), want: "", }, @@ -150,7 +150,10 @@ func TestClientRecordsEachCall(t *testing.T) { if call.number == 1 { w.WriteHeader(http.StatusTooManyRequests) - _, _ = io.WriteString(w, `{"detail": "slow down"}`) + _, err := io.WriteString(w, `{"detail": "slow down"}`) + if err != nil { + panic(err) + } return } @@ -237,22 +240,22 @@ func TestClientFailsWhenTheResponseFails(t *testing.T) { want string }{ { - name: "failed response", + name: "reports the response failure cause", events: []any{map[string]any{"type": "response.failed", "response": map[string]any{"error": map[string]any{"code": "server_error", "message": "busy"}}}}, want: "server_error: busy", }, { - name: "incomplete response", + name: "reports why the response is incomplete", events: []any{map[string]any{"type": "response.incomplete", "response": map[string]any{"incomplete_details": map[string]any{"reason": "content_filter"}}}}, want: "content_filter", }, { - name: "error event", + name: "reports the stream error cause", events: []any{map[string]any{"type": "error", "code": "rate_limit", "message": "too many"}}, want: "rate_limit: too many", }, { - name: "stream ends early", + name: "refuses an unfinished response stream", events: []any{map[string]any{"type": "response.output_item.done", "item": modelMessageItem("cut")}}, want: "ended before the response completed", },