mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-15 16:41:11 -07:00
82 lines
2.6 KiB
TypeScript
82 lines
2.6 KiB
TypeScript
/**
|
||
* @license
|
||
* Copyright 2025 Google LLC
|
||
* SPDX-License-Identifier: Apache-2.0
|
||
*/
|
||
|
||
import { describe, it, expect, vi } from 'vitest';
|
||
import * as os from 'node:os';
|
||
import * as path from 'node:path';
|
||
|
||
vi.mock('fs', async (importOriginal) => {
|
||
const actual = await importOriginal<typeof import('fs')>();
|
||
return {
|
||
...actual,
|
||
mkdirSync: vi.fn(),
|
||
};
|
||
});
|
||
|
||
import { Storage } from './storage.js';
|
||
import { GEMINI_DIR } from '../utils/paths.js';
|
||
|
||
describe('Storage – getGlobalSettingsPath', () => {
|
||
it('returns path to ~/.gemini/settings.json', () => {
|
||
const expected = path.join(os.homedir(), GEMINI_DIR, 'settings.json');
|
||
expect(Storage.getGlobalSettingsPath()).toBe(expected);
|
||
});
|
||
});
|
||
|
||
describe('Storage – additional helpers', () => {
|
||
const projectRoot = '/tmp/project';
|
||
const storage = new Storage(projectRoot);
|
||
|
||
it('getWorkspaceSettingsPath returns project/.gemini/settings.json', () => {
|
||
const expected = path.join(projectRoot, GEMINI_DIR, 'settings.json');
|
||
expect(storage.getWorkspaceSettingsPath()).toBe(expected);
|
||
});
|
||
|
||
it('getUserCommandsDir returns ~/.gemini/commands', () => {
|
||
const expected = path.join(os.homedir(), GEMINI_DIR, 'commands');
|
||
expect(Storage.getUserCommandsDir()).toBe(expected);
|
||
});
|
||
|
||
it('getProjectCommandsDir returns project/.gemini/commands', () => {
|
||
const expected = path.join(projectRoot, GEMINI_DIR, 'commands');
|
||
expect(storage.getProjectCommandsDir()).toBe(expected);
|
||
});
|
||
|
||
it('getUserSkillsDir returns ~/.gemini/skills', () => {
|
||
const expected = path.join(os.homedir(), GEMINI_DIR, 'skills');
|
||
expect(Storage.getUserSkillsDir()).toBe(expected);
|
||
});
|
||
|
||
it('getProjectSkillsDir returns project/.gemini/skills', () => {
|
||
const expected = path.join(projectRoot, GEMINI_DIR, 'skills');
|
||
expect(storage.getProjectSkillsDir()).toBe(expected);
|
||
});
|
||
|
||
it('getUserAgentsDir returns ~/.gemini/agents', () => {
|
||
const expected = path.join(os.homedir(), GEMINI_DIR, 'agents');
|
||
expect(Storage.getUserAgentsDir()).toBe(expected);
|
||
});
|
||
|
||
it('getProjectAgentsDir returns project/.gemini/agents', () => {
|
||
const expected = path.join(projectRoot, GEMINI_DIR, 'agents');
|
||
expect(storage.getProjectAgentsDir()).toBe(expected);
|
||
});
|
||
|
||
it('getMcpOAuthTokensPath returns ~/.gemini/mcp-oauth-tokens.json', () => {
|
||
const expected = path.join(
|
||
os.homedir(),
|
||
GEMINI_DIR,
|
||
'mcp-oauth-tokens.json',
|
||
);
|
||
expect(Storage.getMcpOAuthTokensPath()).toBe(expected);
|
||
});
|
||
|
||
it('getGlobalBinDir returns ~/.gemini/tmp/bin', () => {
|
||
const expected = path.join(os.homedir(), GEMINI_DIR, 'tmp', 'bin');
|
||
expect(Storage.getGlobalBinDir()).toBe(expected);
|
||
});
|
||
});
|