fix fresh-host acceptance and document real-host debugging learnings

This commit is contained in:
phamnazage-jpg
2026-05-21 21:19:19 +08:00
parent 7c6e18f94d
commit 3ba3244ea6
85 changed files with 1721 additions and 162 deletions

View File

@@ -149,7 +149,7 @@ func TestSub2APIHostAdapterTestAccountParsesSSE(t *testing.T) {
t.Fatalf("NewClient() error = %v", err)
}
result, err := client.TestAccount(context.Background(), "account_1")
result, err := client.TestAccount(context.Background(), "account_1", "deepseek-chat")
if err != nil {
t.Fatalf("TestAccount() error = %v", err)
}
@@ -591,7 +591,7 @@ func newSub2APIStubServer(t *testing.T, cfg sub2APIStubConfig) *httptest.Server
})
})
mux.HandleFunc("/v1/models", func(w http.ResponseWriter, r *http.Request) {
if got := r.Header.Get("x-api-key"); got != gatewayExpectedKey {
if got := r.Header.Get("Authorization"); got != "Bearer "+gatewayExpectedKey {
w.WriteHeader(http.StatusUnauthorized)
_, _ = w.Write([]byte(`{"error":"unauthorized"}`))
return
@@ -600,6 +600,26 @@ func newSub2APIStubServer(t *testing.T, cfg sub2APIStubConfig) *httptest.Server
"data": gatewayModels,
})
})
mux.HandleFunc("/v1/chat/completions", func(w http.ResponseWriter, r *http.Request) {
if got := r.Header.Get("Authorization"); got != "Bearer "+gatewayExpectedKey {
w.WriteHeader(http.StatusUnauthorized)
_, _ = w.Write([]byte(`{"error":"unauthorized"}`))
return
}
writeJSON(t, w, http.StatusOK, map[string]any{
"id": "chatcmpl_stub",
"object": "chat.completion",
"choices": []map[string]any{
{
"index": 0,
"message": map[string]any{
"role": "assistant",
"content": "pong",
},
},
},
})
})
return httptest.NewServer(mux)
}