import assert from "node:assert/strict"; import { test } from "node:test"; import { createServer } from "node:http"; // A commit status, set where the pull request shows it (the seat git's status). test("a commit status is set on the commit, under the merge check's context", async () => { const { GiteaClient } = await import("../client.ts"); let seen: { path: string; body: any } | null = null; const server = createServer((req, res) => { let raw = ""; req.on("data", (c) => (raw += c)); req.on("end", () => { seen = { path: `${req.method} ${req.url}`, body: JSON.parse(raw) }; res.statusCode = 201; res.end("{}"); }); }); await new Promise((r) => server.listen(0, r)); const port = (server.address() as any).port; const client = new GiteaClient(`http://127.0.0.1:${port}`, "t"); try { await client.setCommitStatus("novox", "mesh-catalog", "abc1234", { state: "failure", context: "mesh/merge-gate", description: "x" }); } finally { server.close(); } assert.equal(seen!.path, "POST /api/v1/repos/novox/mesh-catalog/statuses/abc1234"); assert.equal(seen!.body.state, "failure"); assert.equal(seen!.body.context, "mesh/merge-gate"); });