mirror of
https://github.com/router-for-me/CLIProxyAPIPlus.git
synced 2026-03-08 06:43:41 +00:00
- Simplified connection logic by removing `connCreateSent` and related state handling. - Updated `buildCodexWebsocketRequestBody` to always use `response.create`. - Added unit tests to validate `response.create` behavior and beta header preservation. - Dropped unsupported `response.append` and outdated `response.done` event types.
37 lines
1.2 KiB
Go
37 lines
1.2 KiB
Go
package executor
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"testing"
|
|
|
|
"github.com/tidwall/gjson"
|
|
)
|
|
|
|
func TestBuildCodexWebsocketRequestBodyPreservesPreviousResponseID(t *testing.T) {
|
|
body := []byte(`{"model":"gpt-5-codex","previous_response_id":"resp-1","input":[{"type":"message","id":"msg-1"}]}`)
|
|
|
|
wsReqBody := buildCodexWebsocketRequestBody(body)
|
|
|
|
if got := gjson.GetBytes(wsReqBody, "type").String(); got != "response.create" {
|
|
t.Fatalf("type = %s, want response.create", got)
|
|
}
|
|
if got := gjson.GetBytes(wsReqBody, "previous_response_id").String(); got != "resp-1" {
|
|
t.Fatalf("previous_response_id = %s, want resp-1", got)
|
|
}
|
|
if gjson.GetBytes(wsReqBody, "input.0.id").String() != "msg-1" {
|
|
t.Fatalf("input item id mismatch")
|
|
}
|
|
if got := gjson.GetBytes(wsReqBody, "type").String(); got == "response.append" {
|
|
t.Fatalf("unexpected websocket request type: %s", got)
|
|
}
|
|
}
|
|
|
|
func TestApplyCodexWebsocketHeadersDefaultsToCurrentResponsesBeta(t *testing.T) {
|
|
headers := applyCodexWebsocketHeaders(context.Background(), http.Header{}, nil, "")
|
|
|
|
if got := headers.Get("OpenAI-Beta"); got != codexResponsesWebsocketBetaHeaderValue {
|
|
t.Fatalf("OpenAI-Beta = %s, want %s", got, codexResponsesWebsocketBetaHeaderValue)
|
|
}
|
|
}
|