summaryrefslogtreecommitdiff
path: root/internal/llm/ollama_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/llm/ollama_test.go')
-rw-r--r--internal/llm/ollama_test.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/internal/llm/ollama_test.go b/internal/llm/ollama_test.go
index 2216e21..e319617 100644
--- a/internal/llm/ollama_test.go
+++ b/internal/llm/ollama_test.go
@@ -49,7 +49,7 @@ func TestBuildOllamaRequest_TempOverride(t *testing.T) {
}
func TestOllama_NameAndModel(t *testing.T) {
- c := newOllama("http://x", "model-x", nil, "").(ollamaClient)
+ c := newOllama("http://x", "model-x", nil, "")
if c.Name() != "ollama" {
t.Fatalf("name: %q", c.Name())
}
@@ -71,7 +71,7 @@ func TestOllamaChat_NoAuthHeaderWhenKeyEmpty(t *testing.T) {
_ = json.NewEncoder(w).Encode(map[string]any{"message": map[string]string{"role": "assistant", "content": "ok"}, "done": true})
}))
defer ts.Close()
- c := newOllama(ts.URL, "m", nil, "").(ollamaClient)
+ c := newOllama(ts.URL, "m", nil, "")
c.httpClient = ts.Client()
if _, err := c.Chat(context.Background(), []Message{{Role: "user", Content: "hi"}}); err != nil {
t.Fatalf("unexpected: %v", err)
@@ -95,7 +95,7 @@ func TestOllamaChat_AuthHeaderWhenKeySet(t *testing.T) {
_ = json.NewEncoder(w).Encode(map[string]any{"message": map[string]string{"role": "assistant", "content": "ok"}, "done": true})
}))
defer ts.Close()
- c := newOllama(ts.URL, "m", f64p(0.1), key).(ollamaClient)
+ c := newOllama(ts.URL, "m", f64p(0.1), key)
c.httpClient = ts.Client()
if _, err := c.Chat(context.Background(), []Message{{Role: "user", Content: "hi"}}); err != nil {
t.Fatalf("unexpected: %v", err)
@@ -110,7 +110,7 @@ func TestOllamaChat_AuthHeaderWhenKeySet(t *testing.T) {
_, _ = w.Write([]byte(`{"message":{"role":"assistant","content":"ok"},"done":true}`))
}))
defer ts.Close()
- c := newOllama(ts.URL, "m", nil, key).(ollamaClient)
+ c := newOllama(ts.URL, "m", nil, key)
c.httpClient = ts.Client()
if err := c.ChatStream(context.Background(), []Message{{Role: "user", Content: "hi"}}, func(string) {}); err != nil {
t.Fatalf("unexpected: %v", err)
@@ -130,7 +130,7 @@ func TestOllamaChat_Success(t *testing.T) {
_ = json.NewEncoder(w).Encode(map[string]any{"message": map[string]string{"role": "assistant", "content": "Hello"}, "done": true})
}))
defer ts.Close()
- c := newOllama(ts.URL, "m", f64p(0.1), "").(ollamaClient)
+ c := newOllama(ts.URL, "m", f64p(0.1), "")
c.httpClient = ts.Client()
out, err := c.Chat(context.Background(), []Message{{Role: "user", Content: "hi"}})
if err != nil {
@@ -149,7 +149,7 @@ func TestOllamaChat_EmptyContent(t *testing.T) {
_ = json.NewEncoder(w).Encode(map[string]any{"message": map[string]string{"role": "assistant", "content": ""}, "done": true})
}))
defer ts.Close()
- c := newOllama(ts.URL, "m", nil, "").(ollamaClient)
+ c := newOllama(ts.URL, "m", nil, "")
c.httpClient = ts.Client()
if _, err := c.Chat(context.Background(), []Message{{Role: "user", Content: "x"}}); err == nil {
t.Fatalf("expected error for empty content")
@@ -166,7 +166,7 @@ func TestOllamaChat_Non2xx(t *testing.T) {
_ = json.NewEncoder(w).Encode(map[string]any{"error": "bad"})
}))
defer ts1.Close()
- c1 := newOllama(ts1.URL, "m", nil, "").(ollamaClient)
+ c1 := newOllama(ts1.URL, "m", nil, "")
c1.httpClient = ts1.Client()
if _, err := c1.Chat(context.Background(), []Message{{Role: "user", Content: "x"}}); err == nil {
t.Fatalf("expected error for 400 with api body")
@@ -177,7 +177,7 @@ func TestOllamaChat_Non2xx(t *testing.T) {
_, _ = w.Write([]byte("{}"))
}))
defer ts2.Close()
- c2 := newOllama(ts2.URL, "m", nil, "").(ollamaClient)
+ c2 := newOllama(ts2.URL, "m", nil, "")
c2.httpClient = ts2.Client()
if _, err := c2.Chat(context.Background(), []Message{{Role: "user", Content: "x"}}); err == nil {
t.Fatalf("expected error for 500")
@@ -189,7 +189,7 @@ type rtFunc func(*http.Request) (*http.Response, error)
func (f rtFunc) RoundTrip(r *http.Request) (*http.Response, error) { return f(r) }
func TestOllamaChat_HTTPError(t *testing.T) {
- c := newOllama("http://127.0.0.1:0", "m", nil, "").(ollamaClient)
+ c := newOllama("http://127.0.0.1:0", "m", nil, "")
c.httpClient = &http.Client{Transport: rtFunc(func(*http.Request) (*http.Response, error) { return nil, fmt.Errorf("boom") })}
if _, err := c.Chat(context.Background(), []Message{{Role: "user", Content: "x"}}); err == nil {
t.Fatalf("expected http error path")
@@ -204,7 +204,7 @@ func TestOllamaChat_DecodeError(t *testing.T) {
_, _ = w.Write([]byte("{bad json}"))
}))
defer ts.Close()
- c := newOllama(ts.URL, "m", nil, "").(ollamaClient)
+ c := newOllama(ts.URL, "m", nil, "")
c.httpClient = ts.Client()
if _, err := c.Chat(context.Background(), []Message{{Role: "user", Content: "x"}}); err == nil {
t.Fatalf("expected decode error")
@@ -229,7 +229,7 @@ func TestOllamaChatStream_Success(t *testing.T) {
_, _ = w.Write([]byte(`{"message":{"role":"assistant","content":"!"},"done":true}`))
}))
defer ts.Close()
- c := newOllama(ts.URL, "m", nil, "").(ollamaClient)
+ c := newOllama(ts.URL, "m", nil, "")
c.httpClient = ts.Client()
var got strings.Builder
if err := c.ChatStream(context.Background(), []Message{{Role: "user", Content: "x"}}, func(s string) { got.WriteString(s) }); err != nil {
@@ -248,7 +248,7 @@ func TestOllamaChatStream_ErrorEvent(t *testing.T) {
_ = json.NewEncoder(w).Encode(map[string]any{"error": "oops"})
}))
defer ts.Close()
- c := newOllama(ts.URL, "m", nil, "").(ollamaClient)
+ c := newOllama(ts.URL, "m", nil, "")
c.httpClient = ts.Client()
if err := c.ChatStream(context.Background(), []Message{{Role: "user", Content: "x"}}, func(string) {}); err == nil {
t.Fatalf("expected stream error")
@@ -263,7 +263,7 @@ func TestOllamaChatStream_DecodeError(t *testing.T) {
_, _ = w.Write([]byte("{not json}"))
}))
defer ts.Close()
- c := newOllama(ts.URL, "m", nil, "").(ollamaClient)
+ c := newOllama(ts.URL, "m", nil, "")
c.httpClient = ts.Client()
if err := c.ChatStream(context.Background(), []Message{{Role: "user", Content: "x"}}, func(string) {}); err == nil {
t.Fatalf("expected decode error")