fix: initialisation of git
This commit is contained in:
@@ -350,4 +350,36 @@ describe('GitEngine', () => {
|
||||
expect(result.error).toContain('install Git LFS');
|
||||
});
|
||||
});
|
||||
|
||||
describe('pruneLfsCache', () => {
|
||||
it('should run git lfs prune with verify-remote by default', async () => {
|
||||
mockRaw.mockResolvedValue('prune complete');
|
||||
|
||||
const result = await gitEngine.pruneLfsCache('/tmp/project');
|
||||
|
||||
expect(mockRaw).toHaveBeenCalledWith(['lfs', 'prune', '--verify-remote']);
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.dryRun).toBe(false);
|
||||
expect(result.verifyRemote).toBe(true);
|
||||
});
|
||||
|
||||
it('should run git lfs prune in dry-run mode when requested', async () => {
|
||||
mockRaw.mockResolvedValue('would prune');
|
||||
|
||||
const result = await gitEngine.pruneLfsCache('/tmp/project', { dryRun: true });
|
||||
|
||||
expect(mockRaw).toHaveBeenCalledWith(['lfs', 'prune', '--verify-remote', '--dry-run']);
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.dryRun).toBe(true);
|
||||
});
|
||||
|
||||
it('should return error result when git lfs prune fails', async () => {
|
||||
mockRaw.mockRejectedValue(new Error('prune failed'));
|
||||
|
||||
const result = await gitEngine.pruneLfsCache('/tmp/project');
|
||||
|
||||
expect(result.success).toBe(false);
|
||||
expect(result.error).toContain('prune failed');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -146,6 +146,7 @@ const mockGitEngine = {
|
||||
getStatus: vi.fn(),
|
||||
initializeRepo: vi.fn(),
|
||||
ensureGitignore: vi.fn(),
|
||||
pruneLfsCache: vi.fn(),
|
||||
};
|
||||
|
||||
const mockTaskManager = {
|
||||
@@ -379,6 +380,22 @@ describe('IPC Handlers', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('git:pruneLfs', () => {
|
||||
it('should pass project path and options to GitEngine.pruneLfsCache', async () => {
|
||||
mockGitEngine.pruneLfsCache.mockResolvedValue({
|
||||
success: true,
|
||||
dryRun: true,
|
||||
verifyRemote: true,
|
||||
output: 'would prune',
|
||||
});
|
||||
|
||||
const result = await invokeHandler('git:pruneLfs', '/repo', { dryRun: true, verifyRemote: true });
|
||||
|
||||
expect(mockGitEngine.pruneLfsCache).toHaveBeenCalledWith('/repo', { dryRun: true, verifyRemote: true });
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// ============ Project Handlers ============
|
||||
|
||||
Reference in New Issue
Block a user