Add support for multiple providers

This commit is contained in:
dwrz
2026-06-19 14:31:41 +00:00
parent c71300b1bf
commit f5e72b1c7a
12 changed files with 948 additions and 869 deletions

View File

@@ -16,23 +16,13 @@ func TestConfigValidate(t *testing.T) {
wantErr: true,
},
{
name: "missing model",
cfg: Config{
URL: "http://localhost:8080",
},
wantErr: true,
},
{
name: "missing URL",
cfg: Config{
Model: "test-model",
},
name: "missing URL",
cfg: Config{},
wantErr: true,
},
{
name: "invalid timeout",
cfg: Config{
Model: "test-model",
URL: "http://localhost:8080",
Timeout: "not-a-duration",
},
@@ -41,15 +31,13 @@ func TestConfigValidate(t *testing.T) {
{
name: "valid minimal config",
cfg: Config{
Model: "test-model",
URL: "http://localhost:8080",
URL: "http://localhost:8080",
},
wantErr: false,
},
{
name: "valid config with timeout",
cfg: Config{
Model: "test-model",
URL: "http://localhost:8080",
Timeout: "15m",
},
@@ -58,7 +46,6 @@ func TestConfigValidate(t *testing.T) {
{
name: "valid config with complex timeout",
cfg: Config{
Model: "test-model",
URL: "http://localhost:8080",
Timeout: "1h30m45s",
},
@@ -68,7 +55,6 @@ func TestConfigValidate(t *testing.T) {
name: "valid full config",
cfg: Config{
Key: "sk-test-key",
Model: "test-model",
SystemMessage: "You are a helpful assistant.",
Timeout: "30m",
URL: "http://localhost:8080",
@@ -104,15 +90,13 @@ func TestNewClient(t *testing.T) {
{
name: "valid config without timeout",
cfg: Config{
Model: "test-model",
URL: "http://localhost:8080",
URL: "http://localhost:8080",
},
wantErr: false,
},
{
name: "valid config with timeout",
cfg: Config{
Model: "test-model",
URL: "http://localhost:8080",
Timeout: "10m",
},
@@ -122,7 +106,6 @@ func TestNewClient(t *testing.T) {
name: "valid config with all fields",
cfg: Config{
Key: "test-key",
Model: "test-model",
SystemMessage: "Test message",
Timeout: "5m",
URL: "http://localhost:8080",
@@ -147,22 +130,3 @@ func TestNewClient(t *testing.T) {
})
}
}
func TestClientDefaultModel(t *testing.T) {
cfg := Config{
Model: "my-custom-model",
URL: "http://localhost:8080",
}
client, err := NewClient(cfg, nil, nil)
if err != nil {
t.Fatalf("NewClient() error = %v", err)
}
if got := client.DefaultModel(); got != "my-custom-model" {
t.Errorf(
"DefaultModel() = %q, want %q",
got, "my-custom-model",
)
}
}