// Static-grep contracts for Task 600 installer additions:
// swap provisioning and rss-sampler service registration.
//
// Why static-grep, not behaviour: the install branches spawn (sudo, systemctl,
// dphys-swapfile), so end-to-end reproduction belongs to the manual smoke path.
// The unit suite pins the branch points so a future refactor that removes them
// fails loudly here.
import test from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { dirname, resolve } from "node:path";
const here = dirname(fileURLToPath(import.meta.url));
const INDEX_TS = resolve(here, "../../src/index.ts");
const SRC = readFileSync(INDEX_TS, "utf-8");
test("installSystemDeps Linux branch installs dphys-swapfile and writes CONF_SWAPSIZE=2048", () => {
    assert.match(SRC, /apt-get.*install.*dphys-swapfile/s, "apt install dphys-swapfile must be present");
    assert.match(SRC, /CONF_SWAPSIZE=2048/, "swap size must be 2048MB");
    assert.match(SRC, /CONF_MAXSWAP=4096/, "swap max must be 4096MB");
    assert.match(SRC, /dphys-swapfile.*restart|restart.*dphys-swapfile/s, "dphys-swapfile service must be restarted");
});
test("installService Linux branch writes rss-sampler user unit and enables it", () => {
    assert.match(SRC, /rss-sampler\.service/, "rss-sampler.service unit must be written");
    assert.match(SRC, /rss-sampler\.sh/, "rss-sampler.sh must appear in ExecStart");
    assert.match(SRC, /rss-sampler.*enable|enable.*rss-sampler/s, "rss-sampler must be enabled");
    assert.match(SRC, /rss-sampler installed/, "rss-sampler install must emit a logFile entry");
});
