test(calculate-version): 補 repository 邊界測試並合併串流攔截輔助

- 補上 GITEA_REPOSITORY 空段/缺斜線/多段等邊界格式的拋錯測試
- 將 logger 測試的 captureStdout/captureStderr 合併為單一 captureStream

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jeffery
2026-06-26 14:05:08 +08:00
co-authored by Claude Opus 4.8
parent da83f4fc30
commit 1e227328f2
2 changed files with 20 additions and 22 deletions
+9
View File
@@ -95,6 +95,15 @@ test('loadConfig 於 GITEA_REPOSITORY 格式錯誤或含路徑穿越時拋錯',
}), /GITEA_REPOSITORY 格式錯誤/);
});
test('loadConfig 於 GITEA_REPOSITORY 邊界格式(空段/缺斜線/多段)皆拋錯', () => {
for (const repo of ['noslash', 'owner/', '/repo', 'a/b/c', 'owner//repo']) {
assert.throws(() => loadConfig({
GITEA_SERVER_URL: 'https://gitea.example.com',
GITEA_REPOSITORY: repo,
}), /GITEA_REPOSITORY 格式錯誤/, `應拒絕:${repo}`);
}
});
test('loadConfig 接受含點號的合法 owner/repo', () => {
const config = loadConfig({
GITEA_SERVER_URL: 'https://gitea.example.com',