mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-21 09:17:53 +00:00
Sync upstream Gemini-CLI v0.8.2 (#838)
This commit is contained in:
@@ -9,25 +9,26 @@ import { getStartupWarnings } from './startupWarnings.js';
|
||||
import * as fs from 'node:fs/promises';
|
||||
import { getErrorMessage } from '@qwen-code/qwen-code-core';
|
||||
|
||||
vi.mock('fs/promises');
|
||||
vi.mock('node:fs/promises', { spy: true });
|
||||
vi.mock('@qwen-code/qwen-code-core', async (importOriginal) => {
|
||||
const actual = await importOriginal();
|
||||
const actual =
|
||||
await importOriginal<typeof import('@qwen-code/qwen-code-core')>();
|
||||
return {
|
||||
...actual,
|
||||
getErrorMessage: vi.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
describe.skip('startupWarnings', () => {
|
||||
describe('startupWarnings', () => {
|
||||
beforeEach(() => {
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
it('should return warnings from the file and delete it', async () => {
|
||||
const mockWarnings = 'Warning 1\nWarning 2';
|
||||
vi.spyOn(fs, 'access').mockResolvedValue();
|
||||
vi.spyOn(fs, 'readFile').mockResolvedValue(mockWarnings);
|
||||
vi.spyOn(fs, 'unlink').mockResolvedValue();
|
||||
vi.mocked(fs.access).mockResolvedValue();
|
||||
vi.mocked(fs.readFile).mockResolvedValue(mockWarnings);
|
||||
vi.mocked(fs.unlink).mockResolvedValue();
|
||||
|
||||
const warnings = await getStartupWarnings();
|
||||
|
||||
@@ -40,7 +41,7 @@ describe.skip('startupWarnings', () => {
|
||||
it('should return an empty array if the file does not exist', async () => {
|
||||
const error = new Error('File not found');
|
||||
(error as Error & { code: string }).code = 'ENOENT';
|
||||
vi.spyOn(fs, 'access').mockRejectedValue(error);
|
||||
vi.mocked(fs.access).mockRejectedValue(error);
|
||||
|
||||
const warnings = await getStartupWarnings();
|
||||
|
||||
@@ -49,7 +50,7 @@ describe.skip('startupWarnings', () => {
|
||||
|
||||
it('should return an error message if reading the file fails', async () => {
|
||||
const error = new Error('Permission denied');
|
||||
vi.spyOn(fs, 'access').mockRejectedValue(error);
|
||||
vi.mocked(fs.access).mockRejectedValue(error);
|
||||
vi.mocked(getErrorMessage).mockReturnValue('Permission denied');
|
||||
|
||||
const warnings = await getStartupWarnings();
|
||||
@@ -61,9 +62,9 @@ describe.skip('startupWarnings', () => {
|
||||
|
||||
it('should return a warning if deleting the file fails', async () => {
|
||||
const mockWarnings = 'Warning 1';
|
||||
vi.spyOn(fs, 'access').mockResolvedValue();
|
||||
vi.spyOn(fs, 'readFile').mockResolvedValue(mockWarnings);
|
||||
vi.spyOn(fs, 'unlink').mockRejectedValue(new Error('Permission denied'));
|
||||
vi.mocked(fs.access).mockResolvedValue();
|
||||
vi.mocked(fs.readFile).mockResolvedValue(mockWarnings);
|
||||
vi.mocked(fs.unlink).mockRejectedValue(new Error('Permission denied'));
|
||||
|
||||
const warnings = await getStartupWarnings();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user