Skip to content

Commit

Permalink
test: add customCommand parameter tests and update test configuration
Browse files Browse the repository at this point in the history
Co-Authored-By: Michael Latman <[email protected]>
  • Loading branch information
devin-ai-integration[bot] and michaellatman committed Dec 15, 2024
1 parent 69a3b2f commit 0a7c578
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions src/utils/__tests__/config-manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,80 @@ describe('ConfigManager', () => {
await expect(ConfigManager.installPackage(mockPackage))
.rejects.toThrow('Custom runtime requires both command and args fields');
});

it('should use customCommand for node runtime when provided', async () => {
const mockPackage: Package = {
name: 'test-package',
description: 'Test package',
runtime: 'node',
vendor: 'test',
sourceUrl: 'https://test.com',
homepage: 'https://test.com',
license: 'MIT'
};

const customCommand = {
command: 'custom-node-cmd',
args: ['--custom-arg']
};

await ConfigManager.installPackage(mockPackage, undefined, customCommand);

expect(mockWriteFileSync).toHaveBeenCalled();
const writtenConfig = JSON.parse(mockWriteFileSync.mock.calls[0][1] as string);
expect(writtenConfig.mcpServers['test-package'].command).toBe('custom-node-cmd');
expect(writtenConfig.mcpServers['test-package'].args).toEqual(['--custom-arg']);
});

it('should use customCommand for python runtime when provided', async () => {
const mockPackage: Package = {
name: 'test-package',
description: 'Test package',
runtime: 'python',
vendor: 'test',
sourceUrl: 'https://test.com',
homepage: 'https://test.com',
license: 'MIT'
};

const customCommand = {
command: 'custom-python-cmd',
args: ['--custom-py-arg']
};

await ConfigManager.installPackage(mockPackage, undefined, customCommand);

expect(mockWriteFileSync).toHaveBeenCalled();
const writtenConfig = JSON.parse(mockWriteFileSync.mock.calls[0][1] as string);
expect(writtenConfig.mcpServers['test-package'].command).toBe('custom-python-cmd');
expect(writtenConfig.mcpServers['test-package'].args).toEqual(['--custom-py-arg']);
});

it('should prioritize package command over customCommand for custom runtime type', async () => {
const mockPackage: Package = {
name: 'test-package',
description: 'Test package',
runtime: 'custom',
vendor: 'test',
sourceUrl: 'https://test.com',
homepage: 'https://test.com',
license: 'MIT',
command: 'specific-cmd',
args: ['--specific-arg']
};

const customCommand = {
command: 'custom-cmd',
args: ['--custom-arg']
};

await ConfigManager.installPackage(mockPackage, undefined, customCommand);

expect(mockWriteFileSync).toHaveBeenCalled();
const writtenConfig = JSON.parse(mockWriteFileSync.mock.calls[0][1] as string);
expect(writtenConfig.mcpServers['test-package'].command).toBe('specific-cmd');
expect(writtenConfig.mcpServers['test-package'].args).toEqual(['--specific-arg']);
});
});

describe('readConfig error handling', () => {
Expand Down

0 comments on commit 0a7c578

Please sign in to comment.