mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-30 23:14:32 -07:00
Fix rough edges around extension updates (#10926)
This commit is contained in:
@@ -8,12 +8,12 @@ import { describe, it, expect, vi, type MockInstance } from 'vitest';
|
||||
import { handleInstall, installCommand } from './install.js';
|
||||
import yargs from 'yargs';
|
||||
|
||||
const mockInstallExtension = vi.hoisted(() => vi.fn());
|
||||
const mockInstallOrUpdateExtension = vi.hoisted(() => vi.fn());
|
||||
const mockRequestConsentNonInteractive = vi.hoisted(() => vi.fn());
|
||||
const mockStat = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock('../../config/extension.js', () => ({
|
||||
installExtension: mockInstallExtension,
|
||||
installOrUpdateExtension: mockInstallOrUpdateExtension,
|
||||
requestConsentNonInteractive: mockRequestConsentNonInteractive,
|
||||
}));
|
||||
|
||||
@@ -51,14 +51,14 @@ describe('handleInstall', () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
mockInstallExtension.mockClear();
|
||||
mockInstallOrUpdateExtension.mockClear();
|
||||
mockRequestConsentNonInteractive.mockClear();
|
||||
mockStat.mockClear();
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it('should install an extension from a http source', async () => {
|
||||
mockInstallExtension.mockResolvedValue('http-extension');
|
||||
mockInstallOrUpdateExtension.mockResolvedValue('http-extension');
|
||||
|
||||
await handleInstall({
|
||||
source: 'http://google.com',
|
||||
@@ -70,7 +70,7 @@ describe('handleInstall', () => {
|
||||
});
|
||||
|
||||
it('should install an extension from a https source', async () => {
|
||||
mockInstallExtension.mockResolvedValue('https-extension');
|
||||
mockInstallOrUpdateExtension.mockResolvedValue('https-extension');
|
||||
|
||||
await handleInstall({
|
||||
source: 'https://google.com',
|
||||
@@ -82,7 +82,7 @@ describe('handleInstall', () => {
|
||||
});
|
||||
|
||||
it('should install an extension from a git source', async () => {
|
||||
mockInstallExtension.mockResolvedValue('git-extension');
|
||||
mockInstallOrUpdateExtension.mockResolvedValue('git-extension');
|
||||
|
||||
await handleInstall({
|
||||
source: 'git@some-url',
|
||||
@@ -104,7 +104,7 @@ describe('handleInstall', () => {
|
||||
});
|
||||
|
||||
it('should install an extension from a sso source', async () => {
|
||||
mockInstallExtension.mockResolvedValue('sso-extension');
|
||||
mockInstallOrUpdateExtension.mockResolvedValue('sso-extension');
|
||||
|
||||
await handleInstall({
|
||||
source: 'sso://google.com',
|
||||
@@ -116,7 +116,7 @@ describe('handleInstall', () => {
|
||||
});
|
||||
|
||||
it('should install an extension from a local path', async () => {
|
||||
mockInstallExtension.mockResolvedValue('local-extension');
|
||||
mockInstallOrUpdateExtension.mockResolvedValue('local-extension');
|
||||
mockStat.mockResolvedValue({});
|
||||
await handleInstall({
|
||||
source: '/some/path',
|
||||
@@ -128,7 +128,7 @@ describe('handleInstall', () => {
|
||||
});
|
||||
|
||||
it('should throw an error if install extension fails', async () => {
|
||||
mockInstallExtension.mockRejectedValue(
|
||||
mockInstallOrUpdateExtension.mockRejectedValue(
|
||||
new Error('Install extension failed'),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user