Files
7000pctAUTO 898b666db0
Some checks failed
CI / test (push) Has been cancelled
fix: Add missing tests directory and files
2026-02-03 08:11:33 +00:00

51 lines
1.5 KiB
TypeScript

import * as path from 'path';
import * as fs from 'fs-extra';
import * as os from 'os';
import simpleGit from 'simple-git';
export async function setupTestRepo(): Promise<string> {
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'gas-test-'));
const repoDir = path.join(tempDir, 'test-repo');
fs.ensureDirSync(repoDir);
const git = simpleGit(repoDir);
await git.init();
await git.addConfig('user.email', 'test@example.com');
await git.addConfig('user.name', 'Test User');
fs.writeFileSync(path.join(repoDir, 'README.md'), '# Test Repository\n');
await git.add('.');
await git.commit('Initial commit');
return repoDir;
}
export async function cleanupTestRepo(repoDir: string): Promise<void> {
await fs.remove(path.dirname(repoDir));
}
export function createMockGit() {
return {
branch: jest.fn().mockResolvedValue({ current: 'main', all: ['main', 'develop'] }),
status: jest.fn().mockResolvedValue({
modified: [],
created: [],
deleted: [],
staged: [],
conflicted: []
}),
diff: jest.fn().mockResolvedValue(''),
raw: jest.fn().mockResolvedValue(''),
add: jest.fn().mockResolvedValue({}),
commit: jest.fn().mockResolvedValue({}),
checkout: jest.fn().mockResolvedValue({}),
pull: jest.fn().mockResolvedValue({}),
stash: jest.fn().mockResolvedValue({}),
log: jest.fn().mockResolvedValue({ latest: null }),
worktree: jest.fn().mockResolvedValue({}),
init: jest.fn().mockResolvedValue({}),
addConfig: jest.fn().mockResolvedValue({})
};
}