feat/sdlc-plan-requirement-issue/main #21
@@ -89,3 +89,17 @@ function safeParse(raw) {
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 啟動假 Gitea 並登記在測試結束時關掉,省去每支測試各寫一次 close。
|
||||
* @param {object} t node:test 的 TestContext
|
||||
* @param {Record<string, object|Function>} routes
|
||||
*/
|
||||
export async function withStubGitea(t, routes) {
|
||||
const stub = await startStubGitea(routes);
|
||||
t.after(() => stub.close());
|
||||
return stub;
|
||||
}
|
||||
|
||||
/** 把腳本指向這台假 Gitea 的環境變數 */
|
||||
export const stubEnv = (stub) => ({ TEA_SDLC_API_BASE: stub.base, TEA_SDLC_TOKEN: 'stub-token' });
|
||||
|
||||
@@ -1,20 +1,15 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { runScript } from './helpers/run-script.js';
|
||||
import { startStubGitea, healthyRoutes } from './helpers/stub-gitea.js';
|
||||
import { healthyRoutes, stubEnv as envFor, withStubGitea } from './helpers/stub-gitea.js';
|
||||
|
||||
const REPO = 'plugins/tea-sdlc';
|
||||
|
||||
/** 讓每個測試都拿到一台乾淨的假 Gitea,並在結束後關掉 */
|
||||
async function withStub(t, overrides = {}) {
|
||||
const stub = await startStubGitea(healthyRoutes(REPO, overrides));
|
||||
t.after(() => stub.close());
|
||||
return stub;
|
||||
return withStubGitea(t, healthyRoutes(REPO, overrides));
|
||||
}
|
||||
|
||||
function envFor(stub) {
|
||||
return { TEA_SDLC_API_BASE: stub.base, TEA_SDLC_TOKEN: 'stub-token' };
|
||||
}
|
||||
|
||||
test('列出目標 repo 的既有標籤,輸出單行 JSON 且 exit 0', async (t) => {
|
||||
const stub = await withStub(t);
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { runScript, pathWithOnly } from './helpers/run-script.js';
|
||||
import { startStubGitea, healthyRoutes } from './helpers/stub-gitea.js';
|
||||
import { healthyRoutes, stubEnv as envFor, withStubGitea } from './helpers/stub-gitea.js';
|
||||
|
||||
const REPO = 'plugins/tea-sdlc';
|
||||
|
||||
async function withStub(t, overrides = {}) {
|
||||
const stub = await startStubGitea(healthyRoutes(REPO, overrides));
|
||||
t.after(() => stub.close());
|
||||
return stub;
|
||||
return withStubGitea(t, healthyRoutes(REPO, overrides));
|
||||
}
|
||||
|
||||
const envFor = (stub) => ({ TEA_SDLC_API_BASE: stub.base, TEA_SDLC_TOKEN: 'stub-token' });
|
||||
|
||||
// ── 第一層:執行環境 ────────────────────────────────────────────────
|
||||
|
||||
|
||||
@@ -6,17 +6,14 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { runScript } from './helpers/run-script.js';
|
||||
import { startStubGitea, healthyRoutes } from './helpers/stub-gitea.js';
|
||||
import { healthyRoutes, stubEnv as envFor, withStubGitea } from './helpers/stub-gitea.js';
|
||||
|
||||
const REPO = 'plugins/tea-sdlc';
|
||||
|
||||
async function withStub(t, overrides = {}) {
|
||||
const stub = await startStubGitea(healthyRoutes(REPO, overrides));
|
||||
t.after(() => stub.close());
|
||||
return stub;
|
||||
return withStubGitea(t, healthyRoutes(REPO, overrides));
|
||||
}
|
||||
|
||||
const envFor = (stub) => ({ TEA_SDLC_API_BASE: stub.base, TEA_SDLC_TOKEN: 'stub-token' });
|
||||
|
||||
// ── 輸入:具名 flag ────────────────────────────────────────────────
|
||||
|
||||
|
||||
Reference in New Issue
Block a user