mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-17 17:41:24 -07:00
Introduce GEMINI_CLI_HOME for strict test isolation (#15907)
This commit is contained in:
@@ -14,8 +14,15 @@ vi.mock('node:child_process', async (importOriginal) => {
|
||||
spawnSync: vi.fn(() => ({ status: 0 })),
|
||||
};
|
||||
});
|
||||
vi.mock('fs');
|
||||
vi.mock('os');
|
||||
vi.mock('node:fs');
|
||||
vi.mock('node:os');
|
||||
vi.mock('../utils/paths.js', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('../utils/paths.js')>();
|
||||
return {
|
||||
...actual,
|
||||
homedir: vi.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
||||
import { getIdeInstaller } from './ide-installer.js';
|
||||
@@ -24,12 +31,14 @@ import * as fs from 'node:fs';
|
||||
import * as os from 'node:os';
|
||||
import * as path from 'node:path';
|
||||
import { IDE_DEFINITIONS, type IdeInfo } from './detect-ide.js';
|
||||
import { homedir as pathsHomedir } from '../utils/paths.js';
|
||||
|
||||
describe('ide-installer', () => {
|
||||
const HOME_DIR = '/home/user';
|
||||
|
||||
beforeEach(() => {
|
||||
vi.spyOn(os, 'homedir').mockReturnValue(HOME_DIR);
|
||||
vi.mocked(pathsHomedir).mockReturnValue(HOME_DIR);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
||||
@@ -8,9 +8,9 @@ import * as child_process from 'node:child_process';
|
||||
import * as process from 'node:process';
|
||||
import * as path from 'node:path';
|
||||
import * as fs from 'node:fs';
|
||||
import * as os from 'node:os';
|
||||
import { IDE_DEFINITIONS, type IdeInfo } from './detect-ide.js';
|
||||
import { GEMINI_CLI_COMPANION_EXTENSION_NAME } from './constants.js';
|
||||
import { homedir } from '../utils/paths.js';
|
||||
|
||||
export interface IdeInstaller {
|
||||
install(): Promise<InstallResult>;
|
||||
@@ -49,7 +49,7 @@ async function findCommand(
|
||||
|
||||
// 2. Check common installation locations.
|
||||
const locations: string[] = [];
|
||||
const homeDir = os.homedir();
|
||||
const homeDir = homedir();
|
||||
|
||||
if (command === 'code' || command === 'code.cmd') {
|
||||
if (platform === 'darwin') {
|
||||
|
||||
Reference in New Issue
Block a user