Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e2af609845 |
+8
-14
@@ -122,20 +122,14 @@ export async function postRuntime(
|
|||||||
const reviewerToken = (await Deno.readTextFile(manifest.reviewerFile))
|
const reviewerToken = (await Deno.readTextFile(manifest.reviewerFile))
|
||||||
.trim();
|
.trim();
|
||||||
const request = async (path: string, body: unknown): Promise<void> => {
|
const request = async (path: string, body: unknown): Promise<void> => {
|
||||||
let response: Response;
|
const response = await fetcher(`${context.apiUrl}/${path}`, {
|
||||||
try {
|
method: "POST",
|
||||||
response = await fetcher(`${context.apiUrl}/${path}`, {
|
headers: {
|
||||||
method: "POST",
|
Authorization: `token ${reviewerToken}`,
|
||||||
headers: {
|
"Content-Type": "application/json",
|
||||||
Authorization: `token ${reviewerToken}`,
|
},
|
||||||
"Content-Type": "application/json",
|
body: JSON.stringify(body),
|
||||||
},
|
});
|
||||||
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) {
|
if (!response.ok) {
|
||||||
throw new GiteaRequestError(
|
throw new GiteaRequestError(
|
||||||
`${path}: ${response.status} ${await response.text()}`,
|
`${path}: ${response.status} ${await response.text()}`,
|
||||||
|
|||||||
@@ -196,24 +196,6 @@ Deno.test("removes runtime credentials when posting fails", async () => {
|
|||||||
assert(await missing(result.runtimeDir));
|
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 () => {
|
Deno.test("refuses to follow an agent artifact symlink", async () => {
|
||||||
if (Deno.build.os === "windows") return;
|
if (Deno.build.os === "windows") return;
|
||||||
const result = await fixture({ ok: true, body: "done" });
|
const result = await fixture({ ok: true, body: "done" });
|
||||||
|
|||||||
Reference in New Issue
Block a user