mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-14 12:00:18 -07:00
Support installing extensions with org/repo (#7364)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> Co-authored-by: Bryan Morgan <bryanmorgan@google.com>
This commit is contained in:
@@ -5,14 +5,19 @@
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { installCommand } from './install.js';
|
||||
import { installCommand, handleInstall } from './install.js';
|
||||
import yargs from 'yargs';
|
||||
import * as extension from '../../config/extension.js';
|
||||
|
||||
vi.mock('../../config/extension.js', () => ({
|
||||
installExtension: vi.fn(),
|
||||
}));
|
||||
|
||||
describe('extensions install command', () => {
|
||||
it('should fail if no source is provided', () => {
|
||||
const validationParser = yargs([]).command(installCommand).fail(false);
|
||||
expect(() => validationParser.parse('install')).toThrow(
|
||||
'Either a git URL --source or a --path must be provided.',
|
||||
'Either --source or --path must be provided.',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -23,3 +28,22 @@ describe('extensions install command', () => {
|
||||
).toThrow('Arguments source and path are mutually exclusive');
|
||||
});
|
||||
});
|
||||
|
||||
describe('extensions install with org/repo', () => {
|
||||
it('should call installExtension with the correct git URL', async () => {
|
||||
const consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {});
|
||||
const installExtensionSpy = vi
|
||||
.spyOn(extension, 'installExtension')
|
||||
.mockResolvedValue('test-extension');
|
||||
|
||||
await handleInstall({ source: 'test-org/test-repo' });
|
||||
|
||||
expect(installExtensionSpy).toHaveBeenCalledWith({
|
||||
source: 'https://github.com/test-org/test-repo.git',
|
||||
type: 'git',
|
||||
});
|
||||
expect(consoleLogSpy).toHaveBeenCalledWith(
|
||||
'Extension "test-extension" installed successfully and enabled.',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user