Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 41f7d6e64f |
+14
-8
@@ -122,14 +122,20 @@ export async function postRuntime(
|
||||
const reviewerToken = (await Deno.readTextFile(manifest.reviewerFile))
|
||||
.trim();
|
||||
const request = async (path: string, body: unknown): Promise<void> => {
|
||||
const response = await fetcher(`${context.apiUrl}/${path}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `token ${reviewerToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
let response: Response;
|
||||
try {
|
||||
response = await fetcher(`${context.apiUrl}/${path}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `token ${reviewerToken}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
} catch (error) {
|
||||
const detail = error instanceof Error ? error.message : String(error);
|
||||
throw new GiteaRequestError(`${path}: ${detail}`, { cause: error });
|
||||
}
|
||||
if (!response.ok) {
|
||||
throw new GiteaRequestError(
|
||||
`${path}: ${response.status} ${await response.text()}`,
|
||||
|
||||
@@ -196,6 +196,24 @@ Deno.test("removes runtime credentials when posting fails", async () => {
|
||||
assert(await missing(result.runtimeDir));
|
||||
});
|
||||
|
||||
Deno.test("preserves a Gitea transport failure without retrying a comment", async () => {
|
||||
const result = await fixture({ ok: true, body: "done" });
|
||||
let requests = 0;
|
||||
|
||||
await assertRejects(
|
||||
() =>
|
||||
postRuntime(result.manifestPath, context, () => {
|
||||
requests++;
|
||||
return Promise.reject(new Error(`network failure ${requests}`));
|
||||
}),
|
||||
Error,
|
||||
"network failure 1",
|
||||
);
|
||||
|
||||
assertEquals(requests, 1);
|
||||
assert(await missing(result.runtimeDir));
|
||||
});
|
||||
|
||||
Deno.test("refuses to follow an agent artifact symlink", async () => {
|
||||
if (Deno.build.os === "windows") return;
|
||||
const result = await fixture({ ok: true, body: "done" });
|
||||
|
||||
Reference in New Issue
Block a user