updater fixed

This commit is contained in:
NuklearRabbit
2026-07-28 00:03:33 +02:00
parent f990c26014
commit d4d77c827a
18 changed files with 451 additions and 71 deletions
+31 -2
View File
@@ -108,18 +108,32 @@ test('creates controlled pull requests and reads branch protection', async () =>
await assert.rejects(() => service.createPullRequest({ owner: 'owner', repo: 'app', head: 'main', base: 'main', title: 'Invalid' }), /different/);
});
test('downloads release assets through the release-scoped Gitea endpoint', async () => {
test('resolves release attachment metadata before downloading the actual asset', async () => {
const service = new GiteaService(makeStore());
let metadataPath = '';
let requested = '';
service.request = async (pathname) => {
metadataPath = pathname;
return {
data: {
id: 412,
browser_download_url: 'https://gitea.example.test/attachments/release.exe',
},
};
};
service.downloadAuthenticated = async (pathname) => {
requested = pathname;
return Buffer.from('asset');
};
const asset = await service.downloadReleaseAsset('Jens', 'ForgeFlow', 107, 412);
assert.equal(asset.toString(), 'asset');
assert.equal(
metadataPath,
'/repos/Jens/ForgeFlow/releases/107/assets/412',
);
assert.equal(
requested,
'/api/v1/repos/Jens/ForgeFlow/releases/107/assets/412',
'https://gitea.example.test/attachments/release.exe',
);
await assert.rejects(
() => service.downloadReleaseAsset('Jens', 'ForgeFlow', null, 412),
@@ -127,6 +141,21 @@ test('downloads release assets through the release-scoped Gitea endpoint', async
);
});
test('uses a release-provided browser download URL without requesting metadata again', async () => {
const service = new GiteaService(makeStore());
service.request = async () => { throw new Error('metadata lookup should not run'); };
let requested = '';
service.downloadAuthenticated = async (pathname) => {
requested = pathname;
return Buffer.from('asset');
};
const asset = await service.downloadReleaseAsset('Jens', 'ForgeFlow', 107, 412, {
downloadUrl: 'https://gitea.example.test/attachments/direct.exe',
});
assert.equal(asset.toString(), 'asset');
assert.equal(requested, 'https://gitea.example.test/attachments/direct.exe');
});
test('creates conservative default branch protection rules', async () => {
const service = new GiteaService(makeStore());
let request = null;