ultisuite-backend/internal/llm/client_test.go
R3D347HR4Y 556d5f416d Enhance API and configuration for contact discovery and public sharing
- Introduced new endpoints for contact discovery, including scanning, listing, and managing discovered contacts.
- Implemented retry logic for handling missing DAV credentials during contact operations.
- Added public share functionality for drive API, allowing users to manage public shares, including upload, delete, and rename operations.
- Updated Nextcloud configuration to support public share links and improved error handling for public share permissions.
- Enhanced logging and validation across contact and drive APIs for better error tracking and user feedback.
- Added tests for new contact matching and ranking functionalities to ensure accuracy and reliability.
2026-06-06 20:27:02 +02:00

43 lines
1.1 KiB
Go

package llm
import (
"context"
"net/http"
"net/http/httptest"
"testing"
)
func TestListModels(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/v1/models" {
t.Fatalf("unexpected path: %s", r.URL.Path)
}
if got := r.Header.Get("Authorization"); got != "Bearer test-key" {
t.Fatalf("unexpected auth header: %q", got)
}
w.Header().Set("Content-Type", "application/json")
_, _ = w.Write([]byte(`{"data":[{"id":"gpt-4o-mini"},{"id":"gpt-4o"},{"id":""}]}`))
}))
defer srv.Close()
client := NewClient()
models, err := client.ListModels(context.Background(), Provider{
BaseURL: srv.URL + "/v1",
APIKey: "test-key",
})
if err != nil {
t.Fatalf("ListModels: %v", err)
}
if len(models) != 2 || models[0] != "gpt-4o-mini" || models[1] != "gpt-4o" {
t.Fatalf("unexpected models: %#v", models)
}
}
func TestListModelsRequiresBaseURL(t *testing.T) {
client := NewClient()
_, err := client.ListModels(context.Background(), Provider{})
if err == nil {
t.Fatal("expected error for empty base_url")
}
}