fix(checkpoint): Prevent silent failure and enable for non-Git projects (#4144)

This commit is contained in:
Abhi
2025-07-14 13:23:51 -04:00
committed by GitHub
parent 2f1d6234de
commit 9dc812dd4b
4 changed files with 38 additions and 19 deletions

View File

@@ -17,6 +17,7 @@ import {
createContentGeneratorConfig,
} from '../core/contentGenerator.js';
import { GeminiClient } from '../core/client.js';
import { GitService } from '../services/gitService.js';
import { loadServerHierarchicalMemory } from '../utils/memoryDiscovery.js';
// Mock dependencies that might be called during Config construction or createServerConfig
@@ -75,6 +76,12 @@ vi.mock('../telemetry/index.js', async (importOriginal) => {
};
});
vi.mock('../services/gitService.js', () => {
const GitServiceMock = vi.fn();
GitServiceMock.prototype.initialize = vi.fn();
return { GitService: GitServiceMock };
});
describe('Server Config (config.ts)', () => {
const MODEL = 'gemini-pro';
const SANDBOX: SandboxConfig = {
@@ -108,6 +115,32 @@ describe('Server Config (config.ts)', () => {
vi.clearAllMocks();
});
describe('initialize', () => {
it('should throw an error if checkpointing is enabled and GitService fails', async () => {
const gitError = new Error('Git is not installed');
(GitService.prototype.initialize as Mock).mockRejectedValue(gitError);
const config = new Config({
...baseParams,
checkpointing: true,
});
await expect(config.initialize()).rejects.toThrow(gitError);
});
it('should not throw an error if checkpointing is disabled and GitService fails', async () => {
const gitError = new Error('Git is not installed');
(GitService.prototype.initialize as Mock).mockRejectedValue(gitError);
const config = new Config({
...baseParams,
checkpointing: false,
});
await expect(config.initialize()).resolves.toBeUndefined();
});
});
describe('refreshAuth', () => {
it('should refresh auth and update config', async () => {
const config = new Config(baseParams);