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:
32
internal/backend/agent/model/openai_url_test.go
Normal file
32
internal/backend/agent/model/openai_url_test.go
Normal 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)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user