chore: import Local-Cursor v1.1.8 source snapshot

Includes the current working directory changes. Historical commits and release binaries are excluded to limit Gitea storage.
Source base: d7515973fbfd6dd2001fa156c483455b8081c7cb
This commit is contained in:
FuDie0915
2026-11-10 01:24:28 +08:00
commit db73cf5a39
337 changed files with 147502 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
package modeladapter
import (
"testing"
)
// 与拉取端 buildModelsEndpoint 的形态矩阵保持对称:
// 聊天调用对 baseURL 带或不带 /v1 应当同样收敛到正确端点。
func TestOpenAIEndpointURLResolvesBaseURLShapes(t *testing.T) {
cases := []struct {
name string
baseURL string
endpoint string
want string
}{
{"裸 host 追加完整端点", "https://example.com", "/v1/responses", "https://example.com/v1/responses"},
{"裸 host 追加 chat completions", "https://example.com", "/v1/chat/completions", "https://example.com/v1/chat/completions"},
{"base 以 /v1 结尾时去重拼接", "https://example.com/v1", "/v1/chat/completions", "https://example.com/v1/chat/completions"},
{"base 以 /v1 结尾时不重复 /v1", "https://example.com/v1/", "/v1/responses", "https://example.com/v1/responses"},
{"base 内嵌 chat completions 时直用", "https://example.com/v1/chat/completions", "/v1/responses", "https://example.com/v1/chat/completions"},
{"base 内嵌 responses 时直用", "https://example.com/v1/responses", "/v1/chat/completions", "https://example.com/v1/responses"},
{"endpoint 为空时回退默认 responses", "https://example.com", "", "https://example.com/v1/responses"},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
if got := OpenAIEndpointURL(tc.baseURL, tc.endpoint); got != tc.want {
t.Fatalf("OpenAIEndpointURL(%q, %q) = %q, 期望 %q", tc.baseURL, tc.endpoint, got, tc.want)
}
})
}
}