import { test } from "node:test"; import assert from "node:assert/strict"; import { readFileSync } from "node:fs"; // The forge's own database pool is capped (issue 1966): the store's connections are shared by every module on the machine. // The caps are config values placed into the env-file, and a changed env-file recreates the container. const env = readFileSync(new URL("../files/server.env", import.meta.url), "utf8"); const manifest = JSON.parse(readFileSync(new URL("../module.json", import.meta.url), "utf8")); test("the forge's pool caps are config values, placed in server.env, and a change recreates the container", () => { const lines = env.split("\n"); const placed: Record = { GITEA__database__MAX_OPEN_CONNS: ["database-max-open-connections", 40], GITEA__database__MAX_IDLE_CONNS: ["database-max-idle-connections", 10], GITEA__database__CONN_MAX_LIFETIME: ["database-connection-lifetime", "5m"], }; for (const [name, [key, def]] of Object.entries(placed)) { assert.ok(lines.includes(`${name}=\${config:${key}}`), `server.env does not place ${key} at ${name}`); assert.equal(manifest.config[key].default, def); assert.equal(manifest.config[key].trusted, false); assert.ok(manifest.config[key].description.includes("100 connections")); } assert.equal(manifest.config["database-max-open-connections"].minimum, 1); const server = manifest.resources.find((r: { id: string }) => r.id === "server"); assert.deepEqual(server["restart-on"], ["server-env"]); });