gateway: add local backend update action
This commit is contained in:
@@ -244,6 +244,45 @@ describe('system handlers', () => {
|
||||
expect(getPath(result.result, 'status', 'activeState')).toBe('active');
|
||||
});
|
||||
|
||||
it('system.localBackendControl accepts update action', async () => {
|
||||
const controlLocalBackend = vi.fn(async (): Promise<LocalBackendControlResult> => ({
|
||||
backend: 'ollama',
|
||||
action: 'update',
|
||||
status: {
|
||||
id: 'ollama',
|
||||
provider: 'ollama',
|
||||
name: 'Ollama',
|
||||
unit: 'ollama.service',
|
||||
configured: true,
|
||||
loadState: 'loaded',
|
||||
activeState: 'active',
|
||||
subState: 'running',
|
||||
unitFileState: 'enabled',
|
||||
description: 'Ollama Service',
|
||||
pid: 321,
|
||||
result: 'success',
|
||||
statusText: 'active (running)',
|
||||
availableActions: ['restart', 'stop', 'update'],
|
||||
},
|
||||
message: 'Updated 2 model(s).',
|
||||
updatedModels: ['llama3.2', 'nomic-embed-text'],
|
||||
}));
|
||||
const handlers = createSystemHandlers({
|
||||
...deps,
|
||||
controlLocalBackend,
|
||||
});
|
||||
|
||||
const req: GatewayRequest = {
|
||||
id: 41,
|
||||
method: 'system.localBackendControl',
|
||||
params: { backend: 'ollama', action: 'update' },
|
||||
};
|
||||
const result = await handlers['system.localBackendControl'](req) as GatewayResponse;
|
||||
expect(controlLocalBackend).toHaveBeenCalledWith('ollama', 'update');
|
||||
expect(getPath(result.result, 'action')).toBe('update');
|
||||
expect(getPath(result.result, 'updatedModels')).toEqual(['llama3.2', 'nomic-embed-text']);
|
||||
});
|
||||
|
||||
it('system.presence returns empty result when getPresence is not provided', async () => {
|
||||
const req: GatewayRequest = { id: 4, method: 'system.presence' };
|
||||
const result = await handlers['system.presence'](req) as GatewayResponse;
|
||||
|
||||
Reference in New Issue
Block a user