mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-14 05:42:54 -07:00
test(cleanup): fix temporary directory leaks in test suites (#26217)
This commit is contained in:
@@ -45,6 +45,7 @@ import type { ResourceRegistry } from '../resources/resource-registry.js';
|
||||
import * as fs from 'node:fs';
|
||||
import * as os from 'node:os';
|
||||
import * as path from 'node:path';
|
||||
import { cleanupTmpDir } from '@google/gemini-cli-test-utils';
|
||||
import { coreEvents } from '../utils/events.js';
|
||||
import type { EnvironmentSanitizationConfig } from '../services/environmentSanitization.js';
|
||||
|
||||
@@ -105,9 +106,11 @@ describe('mcp-client', () => {
|
||||
workspaceContext = new WorkspaceContext(testWorkspace);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
afterEach(async () => {
|
||||
vi.useRealTimers();
|
||||
await cleanupTmpDir(testWorkspace);
|
||||
workspaceContext = null as unknown as WorkspaceContext;
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
describe('McpClient', () => {
|
||||
@@ -2410,7 +2413,10 @@ describe('connectToMcpServer with OAuth', () => {
|
||||
vi.mocked(MCPOAuthProvider).mockReturnValue(mockAuthProvider);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
afterEach(async () => {
|
||||
vi.useRealTimers();
|
||||
await cleanupTmpDir(testWorkspace);
|
||||
workspaceContext = null as unknown as WorkspaceContext;
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
@@ -2617,7 +2623,10 @@ describe('connectToMcpServer - HTTP→SSE fallback', () => {
|
||||
vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
afterEach(async () => {
|
||||
vi.useRealTimers();
|
||||
await cleanupTmpDir(testWorkspace);
|
||||
workspaceContext = null as unknown as WorkspaceContext;
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
@@ -2780,7 +2789,10 @@ describe('connectToMcpServer - OAuth with transport fallback', () => {
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
afterEach(async () => {
|
||||
vi.useRealTimers();
|
||||
await cleanupTmpDir(testWorkspace);
|
||||
workspaceContext = null as unknown as WorkspaceContext;
|
||||
vi.clearAllMocks();
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user