|
| 1 | +import { OllamaEngine } from '../../src/engine/ollama'; |
| 2 | + |
| 3 | +describe('OllamaEngine', () => { |
| 4 | + it('sends think=false when configured', async () => { |
| 5 | + const engine = new OllamaEngine({ |
| 6 | + apiKey: 'ollama', |
| 7 | + model: 'qwen3.5:2b', |
| 8 | + maxTokensOutput: 500, |
| 9 | + maxTokensInput: 4096, |
| 10 | + ollamaThink: false |
| 11 | + }); |
| 12 | + |
| 13 | + const post = jest.fn().mockResolvedValue({ |
| 14 | + data: { |
| 15 | + message: { |
| 16 | + content: 'feat: add support for ollama think config' |
| 17 | + } |
| 18 | + } |
| 19 | + }); |
| 20 | + |
| 21 | + engine.client = { post } as any; |
| 22 | + |
| 23 | + await engine.generateCommitMessage([ |
| 24 | + { role: 'user', content: 'diff --git a/file b/file' } |
| 25 | + ]); |
| 26 | + |
| 27 | + expect(post).toHaveBeenCalledWith( |
| 28 | + 'http://localhost:11434/api/chat', |
| 29 | + expect.objectContaining({ |
| 30 | + think: false |
| 31 | + }) |
| 32 | + ); |
| 33 | + }); |
| 34 | + |
| 35 | + it('omits think when not configured', async () => { |
| 36 | + const engine = new OllamaEngine({ |
| 37 | + apiKey: 'ollama', |
| 38 | + model: 'qwen3.5:2b', |
| 39 | + maxTokensOutput: 500, |
| 40 | + maxTokensInput: 4096 |
| 41 | + }); |
| 42 | + |
| 43 | + const post = jest.fn().mockResolvedValue({ |
| 44 | + data: { |
| 45 | + message: { |
| 46 | + content: 'feat: add support for ollama think config' |
| 47 | + } |
| 48 | + } |
| 49 | + }); |
| 50 | + |
| 51 | + engine.client = { post } as any; |
| 52 | + |
| 53 | + await engine.generateCommitMessage([ |
| 54 | + { role: 'user', content: 'diff --git a/file b/file' } |
| 55 | + ]); |
| 56 | + |
| 57 | + expect(post).toHaveBeenCalledWith( |
| 58 | + 'http://localhost:11434/api/chat', |
| 59 | + expect.not.objectContaining({ |
| 60 | + think: expect.anything() |
| 61 | + }) |
| 62 | + ); |
| 63 | + }); |
| 64 | +}); |
0 commit comments