mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
feat(api): align provider creation with presets/custom/google sdk
This commit is contained in:
@@ -39,8 +39,8 @@ func TestCreateProviderPreset_OpenAI_SetsBaseURL(t *testing.T) {
|
||||
if got.Type != "openai" {
|
||||
t.Fatalf("expected type openai, got %q", got.Type)
|
||||
}
|
||||
if got.BaseURL != "https://api.openai.com" {
|
||||
t.Fatalf("expected base_url=https://api.openai.com, got %q", got.BaseURL)
|
||||
if got.BaseURL != "https://api.openai.com/v1" {
|
||||
t.Fatalf("expected base_url=https://api.openai.com/v1, got %q", got.BaseURL)
|
||||
}
|
||||
if got.Name == "" {
|
||||
t.Fatalf("expected generated name")
|
||||
@@ -68,3 +68,25 @@ func TestCreateProviderCustom_RequiresBaseURL(t *testing.T) {
|
||||
t.Fatalf("expected 400, got %d body=%s", rr.Code, rr.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
func TestCreateProviderGoogle_GeminiRequiresAPIKey(t *testing.T) {
|
||||
h, _ := newTestHandler(t)
|
||||
|
||||
r := gin.New()
|
||||
r.POST("/admin/providers/google", h.CreateProviderGoogle)
|
||||
|
||||
reqBody := map[string]any{
|
||||
"type": "gemini",
|
||||
"models": []string{"gemini-2.0-flash"},
|
||||
}
|
||||
b, _ := json.Marshal(reqBody)
|
||||
|
||||
req := httptest.NewRequest(http.MethodPost, "/admin/providers/google", bytes.NewReader(b))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
rr := httptest.NewRecorder()
|
||||
r.ServeHTTP(rr, req)
|
||||
|
||||
if rr.Code != http.StatusBadRequest {
|
||||
t.Fatalf("expected 400, got %d body=%s", rr.Code, rr.Body.String())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user