Skip to main content
Glama
pull.test.ts1.24 kB
import { describe, it, expect, beforeEach, vi } from 'vitest'; import { Ollama } from 'ollama'; import { pullModel, toolDefinition } from '../../src/tools/pull.js'; import { ResponseFormat } from '../../src/types.js'; describe('pullModel', () => { let ollama: Ollama; let mockPull: ReturnType<typeof vi.fn>; beforeEach(() => { mockPull = vi.fn(); ollama = { pull: mockPull, } as any; }); it('should pull a model from registry', async () => { mockPull.mockResolvedValue({ status: 'success', }); const result = await pullModel( ollama, 'llama3.2:latest', false, ResponseFormat.JSON ); expect(typeof result).toBe('string'); expect(mockPull).toHaveBeenCalledTimes(1); expect(mockPull).toHaveBeenCalledWith({ model: 'llama3.2:latest', insecure: false, stream: false, }); const parsed = JSON.parse(result); expect(parsed).toHaveProperty('status'); }); it('should work through toolDefinition handler', async () => { const result = await toolDefinition.handler( ollama, { model: 'llama3.2:latest', format: 'json' }, ResponseFormat.JSON ); expect(typeof result).toBe('string'); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rawveg/ollama-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server