some more oc fixes
This commit is contained in:
+22
-2
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user