"use strict";
// acceptance gate for the env-vs-disk validator. Pure-function
// shape (no I/O, no env read, no exit) keeps the test fast and lets the
// caller (platform/ui/server/index.ts) own the side-effects (console.error +
// process.exit). The four cases cover every observable boot state — missing,
// no-on-disk-account, mismatch, ok — with no fallback path.
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_test_1 = __importDefault(require("node:test"));
const strict_1 = __importDefault(require("node:assert/strict"));
const index_js_1 = require("../index.js");
const UUID_A = "11111111-2222-3333-4444-555555555555";
const UUID_B = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee";
(0, node_test_1.default)("validateAccountIdEnv ok when env matches a disk account", () => {
    const result = (0, index_js_1.validateAccountIdEnv)(UUID_A, [UUID_A]);
    strict_1.default.deepEqual(result, { ok: true, envId: UUID_A, diskIds: [UUID_A] });
});
(0, node_test_1.default)("validateAccountIdEnv FATAL reason=missing when env is undefined", () => {
    const result = (0, index_js_1.validateAccountIdEnv)(undefined, [UUID_A]);
    strict_1.default.equal(result.ok, false);
    strict_1.default.equal(result.ok ? null : result.reason, "missing");
    strict_1.default.equal(result.envId, null);
});
(0, node_test_1.default)("validateAccountIdEnv FATAL reason=missing when env is the empty string", () => {
    // Empty string is the systemd shape when `Environment=ACCOUNT_ID=` lands
    // without a value (e.g. an installer regression that interpolates an empty
    // template variable). Same FATAL classification as undefined — we never
    // accept a falsy env value and silently degrade.
    const result = (0, index_js_1.validateAccountIdEnv)("", [UUID_A]);
    strict_1.default.equal(result.ok, false);
    strict_1.default.equal(result.ok ? null : result.reason, "missing");
});
(0, node_test_1.default)("validateAccountIdEnv FATAL reason=no-on-disk-account when disk is empty", () => {
    const result = (0, index_js_1.validateAccountIdEnv)(UUID_A, []);
    strict_1.default.equal(result.ok, false);
    strict_1.default.equal(result.ok ? null : result.reason, "no-on-disk-account");
    strict_1.default.equal(result.envId, UUID_A);
    strict_1.default.deepEqual(result.diskIds, []);
});
(0, node_test_1.default)("validateAccountIdEnv FATAL reason=mismatch when env not in disk list", () => {
    const result = (0, index_js_1.validateAccountIdEnv)(UUID_A, [UUID_B]);
    strict_1.default.equal(result.ok, false);
    strict_1.default.equal(result.ok ? null : result.reason, "mismatch");
    strict_1.default.equal(result.envId, UUID_A);
    strict_1.default.deepEqual(result.diskIds, [UUID_B]);
});
(0, node_test_1.default)("validateAccountIdEnv ok when env matches one of multiple disk accounts", () => {
    // Phase 0 invariant is single-account, but the validator is shape-agnostic;
    // future multi-account expansion should not require a code change here.
    const result = (0, index_js_1.validateAccountIdEnv)(UUID_B, [UUID_A, UUID_B]);
    strict_1.default.equal(result.ok, true);
});
//# sourceMappingURL=validate-env.test.js.map