6a113659c8
CI Feature / Load example-gitea-env.conf to pipeline env (push) Successful in 22s
acc-tests Cucumber test report
CI Feature / Cucumber tests (push) Successful in 1m13s
unit-tests Bats test report
CI Feature / Bats tests (push) Successful in 1m26s
CI Feature / Report Summary (push) Successful in 5s
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
const { execSync, spawn } = require('child_process');
|
|
const { Before, After, Given } = require('@cucumber/cucumber');
|
|
const path = require('path');
|
|
|
|
const PROJECT_ROOT = path.resolve(__dirname, '..', '..', '..');
|
|
const MOCK_SCRIPT = path.join(PROJECT_ROOT, 'tests', 'helpers', 'mock-api.sh');
|
|
|
|
Before({ tags: '@mock' }, function () {
|
|
const out = execSync(`bash -c 'source "${MOCK_SCRIPT}" && mock_start && sleep 1 && curl -s -o /dev/null -w "%{http_code}" --max-time 3 http://localhost:18080/api/v1/repos/health/check'`, {
|
|
cwd: PROJECT_ROOT,
|
|
encoding: 'utf-8',
|
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
});
|
|
const trimmed = out.trim();
|
|
if (!trimmed.startsWith('2') && !trimmed.startsWith('4')) {
|
|
throw new Error(`Mock server failed to start (HTTP ${trimmed})`);
|
|
}
|
|
});
|
|
|
|
After({ tags: '@mock' }, function () {
|
|
try {
|
|
execSync(`bash -c 'source "${MOCK_SCRIPT}" && mock_stop'`, {
|
|
cwd: PROJECT_ROOT,
|
|
stdio: 'ignore',
|
|
});
|
|
} catch (_) { /* ignore */ }
|
|
});
|
|
|
|
Given('a project repository exists in Gitea', function () {
|
|
});
|
|
|
|
Given('a commit has been pushed to the repository', function () {
|
|
});
|