Skip to content

Commit 1644218

Browse files
committed
fix: update error messages in Ollama embedder validation to use translation keys
1 parent 9caf8f3 commit 1644218

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/services/code-index/embedders/__tests__/ollama.spec.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ describe("CodeIndexOllamaEmbedder", () => {
127127
const result = await embedder.validateConfiguration()
128128

129129
expect(result.valid).toBe(false)
130-
expect(result.error).toBe("Connection to Ollama timed out at http://localhost:11434")
130+
expect(result.error).toBe("embeddings:ollama.serviceNotRunning")
131131
})
132132

133133
it("should fail validation when tags endpoint returns 404", async () => {
@@ -141,9 +141,7 @@ describe("CodeIndexOllamaEmbedder", () => {
141141
const result = await embedder.validateConfiguration()
142142

143143
expect(result.valid).toBe(false)
144-
expect(result.error).toBe(
145-
"Ollama service is not running at http://localhost:11434. Please start Ollama first.",
146-
)
144+
expect(result.error).toBe("embeddings:ollama.serviceNotRunning")
147145
})
148146

149147
it("should fail validation when tags endpoint returns other error", async () => {
@@ -157,7 +155,7 @@ describe("CodeIndexOllamaEmbedder", () => {
157155
const result = await embedder.validateConfiguration()
158156

159157
expect(result.valid).toBe(false)
160-
expect(result.error).toBe("Ollama service is unavailable at http://localhost:11434. HTTP status: 500")
158+
expect(result.error).toBe("embeddings:ollama.serviceUnavailable")
161159
})
162160

163161
it("should fail validation when model does not exist", async () => {
@@ -176,9 +174,7 @@ describe("CodeIndexOllamaEmbedder", () => {
176174
const result = await embedder.validateConfiguration()
177175

178176
expect(result.valid).toBe(false)
179-
expect(result.error).toBe(
180-
"Model 'nomic-embed-text' not found. Available models: llama2:latest, mistral:latest",
181-
)
177+
expect(result.error).toBe("embeddings:ollama.modelNotFound")
182178
})
183179

184180
it("should fail validation when model exists but doesn't support embeddings", async () => {
@@ -205,7 +201,7 @@ describe("CodeIndexOllamaEmbedder", () => {
205201
const result = await embedder.validateConfiguration()
206202

207203
expect(result.valid).toBe(false)
208-
expect(result.error).toBe("Model 'nomic-embed-text' is not embedding capable")
204+
expect(result.error).toBe("embeddings:ollama.modelNotEmbeddingCapable")
209205
})
210206

211207
it("should handle ECONNREFUSED errors", async () => {
@@ -214,7 +210,7 @@ describe("CodeIndexOllamaEmbedder", () => {
214210
const result = await embedder.validateConfiguration()
215211

216212
expect(result.valid).toBe(false)
217-
expect(result.error).toBe("Connection to Ollama timed out at http://localhost:11434")
213+
expect(result.error).toBe("embeddings:ollama.serviceNotRunning")
218214
})
219215

220216
it("should handle ENOTFOUND errors", async () => {
@@ -223,7 +219,7 @@ describe("CodeIndexOllamaEmbedder", () => {
223219
const result = await embedder.validateConfiguration()
224220

225221
expect(result.valid).toBe(false)
226-
expect(result.error).toBe("Ollama host not found: http://localhost:11434")
222+
expect(result.error).toBe("embeddings:ollama.hostNotFound")
227223
})
228224

229225
it("should handle generic network errors", async () => {

0 commit comments

Comments
 (0)