some more oc fixes

This commit is contained in:
Luxferre
2026-09-18 14:25:13 +03:00
parent f23c9132ce
commit 0cc2987dcb
3 changed files with 25 additions and 4 deletions
+22 -2
View File
@@ -1254,8 +1254,8 @@ func TestApplyLLMHeadersOpencode(t *testing.T) {
if got := req.Header.Get("x-opencode-client"); got != "cli" {
t.Errorf("x-opencode-client = %q, want cli", got)
}
if got := req.Header.Get("x-opencode-project"); got != projectID() {
t.Errorf("x-opencode-project = %q, want %q", got, projectID())
if got := req.Header.Get("x-opencode-project"); got != "global" {
t.Errorf("x-opencode-project = %q, want global", got)
}
if got := req.Header.Get("x-opencode-session"); got != opencodeSessionID() {
t.Errorf("x-opencode-session = %q, want %q", got, opencodeSessionID())
@@ -1271,6 +1271,26 @@ func TestApplyLLMHeadersOpencode(t *testing.T) {
}
}
func TestApplyLLMHeadersRequestID(t *testing.T) {
cfg := defCfg
cfg.Endpoint = "https://opencode.ai/zen/v1"
cfg.APIKey = "-"
req, _ := http.NewRequest("POST", "https://opencode.ai/zen/v1/chat/completions", nil)
applyLLMHeaders(req, &cfg, ocRequestID())
got := req.Header.Get("x-opencode-request")
if !strings.HasPrefix(got, "msg_") {
t.Errorf("x-opencode-request = %q, want msg_ prefix", got)
}
if len(got) != 30 {
t.Errorf("x-opencode-request length = %d, want 30: %q", len(got), got)
}
for _, c := range got[4:] {
if !strings.ContainsRune(opencodeIDAlphabet, c) {
t.Errorf("invalid character %c in x-opencode-request %q", c, got)
}
}
}
func TestApplyLLMHeadersOpencodeAuth(t *testing.T) {
cfg := defCfg
cfg.Endpoint = "https://opencode.ai/zen/v1"