summaryrefslogtreecommitdiff
path: root/internal/llm/ollama_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-09-06 10:25:36 +0300
committerPaul Buetow <paul@buetow.org>2025-09-06 10:25:36 +0300
commit5be9532cfa630f4aacd8d879c3e4f5cc316da0fa (patch)
tree0a901680fccd1e2703ffdbd9284ccff932be1d67 /internal/llm/ollama_test.go
parent70f1d0e78c57dfa5beae779b3d392b6e6fa44c14 (diff)
feat(lsp): configurable inline/chat triggers; switch inline markers to >text>/>>text>; update docs and example config; tests updated to new triggers and raise LSP coverage to >=85%; chore: remove semicolon legacy; chore(mage): auto-refresh coverage daily if docs/coverage.out is older than 24h
Diffstat (limited to 'internal/llm/ollama_test.go')
-rw-r--r--internal/llm/ollama_test.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/internal/llm/ollama_test.go b/internal/llm/ollama_test.go
index 8d77a58..15f9cff 100644
--- a/internal/llm/ollama_test.go
+++ b/internal/llm/ollama_test.go
@@ -9,6 +9,7 @@ import (
"strings"
"testing"
"time"
+ "os"
)
func TestBuildOllamaRequest_OptionsAndStream(t *testing.T) {
@@ -40,6 +41,7 @@ func TestOllama_NameAndModel(t *testing.T) {
}
func TestOllamaChat_Success(t *testing.T) {
+ if os.Getenv("HEXAI_TEST_SKIP_NET") == "1" { t.Skip("skip network-bound tests in restricted environments") }
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost || r.URL.Path != "/api/chat" { t.Fatalf("unexpected request: %s %s", r.Method, r.URL.Path) }
w.Header().Set("Content-Type", "application/json")
@@ -54,6 +56,7 @@ func TestOllamaChat_Success(t *testing.T) {
}
func TestOllamaChat_EmptyContent(t *testing.T) {
+ if os.Getenv("HEXAI_TEST_SKIP_NET") == "1" { t.Skip("skip network-bound tests in restricted environments") }
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_ = json.NewEncoder(w).Encode(map[string]any{"message": map[string]string{"role":"assistant","content":""}, "done": true})
}))
@@ -66,6 +69,7 @@ func TestOllamaChat_EmptyContent(t *testing.T) {
}
func TestOllamaChat_Non2xx(t *testing.T) {
+ if os.Getenv("HEXAI_TEST_SKIP_NET") == "1" { t.Skip("skip network-bound tests in restricted environments") }
// API error string
ts1 := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(400)
@@ -102,6 +106,7 @@ func TestOllamaChat_HTTPError(t *testing.T) {
}
func TestOllamaChat_DecodeError(t *testing.T) {
+ if os.Getenv("HEXAI_TEST_SKIP_NET") == "1" { t.Skip("skip network-bound tests in restricted environments") }
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, _ = w.Write([]byte("{bad json}"))
}))
@@ -119,6 +124,7 @@ func TestHandleOllamaNon2xx_OK(t *testing.T) {
}
func TestOllamaChatStream_Success(t *testing.T) {
+ if os.Getenv("HEXAI_TEST_SKIP_NET") == "1" { t.Skip("skip network-bound tests in restricted environments") }
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
// two JSON objects back-to-back
@@ -136,6 +142,7 @@ func TestOllamaChatStream_Success(t *testing.T) {
}
func TestOllamaChatStream_ErrorEvent(t *testing.T) {
+ if os.Getenv("HEXAI_TEST_SKIP_NET") == "1" { t.Skip("skip network-bound tests in restricted environments") }
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_ = json.NewEncoder(w).Encode(map[string]any{"error":"oops"})
}))
@@ -148,6 +155,7 @@ func TestOllamaChatStream_ErrorEvent(t *testing.T) {
}
func TestOllamaChatStream_DecodeError(t *testing.T) {
+ if os.Getenv("HEXAI_TEST_SKIP_NET") == "1" { t.Skip("skip network-bound tests in restricted environments") }
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, _ = w.Write([]byte("{not json}"))
}))