From db82e56378d288fb73f7d60e36be5c5088ef0b53 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Tue, 3 Feb 2026 07:58:10 +0000 Subject: [PATCH] Add tests, templates, and Gitea Actions workflows --- .tests/integration/helpers.ts | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .tests/integration/helpers.ts diff --git a/.tests/integration/helpers.ts b/.tests/integration/helpers.ts new file mode 100644 index 0000000..ad4a4d6 --- /dev/null +++ b/.tests/integration/helpers.ts @@ -0,0 +1,50 @@ +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 { + 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 { + 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({}) + }; +}