test(calculate-version): 補上 GITEA_SERVER_URL 驗證與 main 失敗路徑測試
新增 config 的 URL 格式/協定驗證測試,以及以相依注入覆蓋 main 成功與 loadConfig/fetchReleases 失敗路徑的整合測試。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
fdf33b41d8
commit
3c8704d1a3
@@ -59,3 +59,17 @@ test('loadConfig 缺少 token 視為匿名(null)', () => {
|
||||
test('loadConfig 缺少必填項目時拋錯', () => {
|
||||
assert.throws(() => loadConfig({ GITEA_REPOSITORY: 'owner/repo' }), /GITEA_SERVER_URL 未設定/);
|
||||
});
|
||||
|
||||
test('loadConfig 於 GITEA_SERVER_URL 非合法 URL 時拋錯', () => {
|
||||
assert.throws(() => loadConfig({
|
||||
GITEA_SERVER_URL: 'not-a-url',
|
||||
GITEA_REPOSITORY: 'owner/repo',
|
||||
}), /GITEA_SERVER_URL 格式錯誤/);
|
||||
});
|
||||
|
||||
test('loadConfig 於 GITEA_SERVER_URL 使用非 http(s) 協定時拋錯', () => {
|
||||
assert.throws(() => loadConfig({
|
||||
GITEA_SERVER_URL: 'ftp://gitea.example.com',
|
||||
GITEA_REPOSITORY: 'owner/repo',
|
||||
}), /必須使用 http 或 https/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user