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:
christine betts
2025-09-02 08:15:47 -07:00
committed by GitHub
parent a210fd8395
commit 8a7f4ffcc1
2 changed files with 65 additions and 11 deletions
@@ -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.',
);
});
});