a3e9982d49
The Ollama provider now targets /api/chat directly via the native provider introduced in the previous commits. Public API is unchanged for callers that go through llm.Ollama() (and is extended by Task 5's OllamaCloud() constructor). DefaultBaseURL was renamed to DefaultLocalBaseURL (without the trailing /v1 segment used by the OpenAI-compat path). registry.go is updated correspondingly; no other callers referenced the old name. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
36 lines
930 B
Go
36 lines
930 B
Go
package ollama
|
|
|
|
import "testing"
|
|
|
|
func TestNew(t *testing.T) {
|
|
t.Run("local mode picks default local URL", func(t *testing.T) {
|
|
p := New("", "")
|
|
if p == nil {
|
|
t.Fatal("New returned nil")
|
|
}
|
|
if p.baseURL != DefaultLocalBaseURL {
|
|
t.Errorf("baseURL: want %q, got %q", DefaultLocalBaseURL, p.baseURL)
|
|
}
|
|
if p.apiKey != "" {
|
|
t.Errorf("apiKey: want empty, got %q", p.apiKey)
|
|
}
|
|
})
|
|
|
|
t.Run("cloud mode (apiKey set) picks cloud URL", func(t *testing.T) {
|
|
p := New("test-key", "")
|
|
if p.baseURL != DefaultCloudBaseURL {
|
|
t.Errorf("baseURL: want %q, got %q", DefaultCloudBaseURL, p.baseURL)
|
|
}
|
|
if p.apiKey != "test-key" {
|
|
t.Errorf("apiKey: want %q, got %q", "test-key", p.apiKey)
|
|
}
|
|
})
|
|
|
|
t.Run("explicit baseURL is preserved", func(t *testing.T) {
|
|
p := New("k", "http://example.test:9999")
|
|
if p.baseURL != "http://example.test:9999" {
|
|
t.Errorf("baseURL not preserved, got %q", p.baseURL)
|
|
}
|
|
})
|
|
}
|