08919752e3
Checkpoint multi-chantiers (arbre vert : tsc 0 erreur, 70 tests, build OK). - tâche 1.9 Phase 1 : schéma socle (machine_state/events/reports/raw_artifacts/ hardware/metrics + colonnes étendues) + wiring refresh/execute. Migration 0002. - tâche 1.9 Phase 2 : machine_credentials + machine_host_keys (non destructif, dual-read + backfill). Migration 0003. Fix séquence journal de migration. - tâche 2 : SJ-0 (types étendus rétro-compatibles, réducteur Docker, resolveTemplate), SJ-1 (update-analyze enrichi), SJ-2 (apply + diff dpkg + timeout inactivité SSH), SJ-3 (reboot vérifié boot_id). - WIP parallèle inclus : /api/capabilities, auth/apiTokens/apiClients, system metrics, scaffold app_rust, ajustements frontend. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
28 lines
1.3 KiB
TypeScript
28 lines
1.3 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { classifyReboot, parseBootIdBefore } from "./rebootVerify.js";
|
|
|
|
describe("parseBootIdBefore", () => {
|
|
it("extrait le boot_id de la sortie du template", () => {
|
|
const raw = "===SU:BOOT_ID_BEFORE===\nabcd-1234\n===SU:REBOOT_NOW===\nreboot planifié";
|
|
expect(parseBootIdBefore(raw)).toBe("abcd-1234");
|
|
});
|
|
it("retourne null si absent", () => {
|
|
expect(parseBootIdBefore("rien")).toBeNull();
|
|
});
|
|
});
|
|
|
|
describe("classifyReboot", () => {
|
|
it("ok si la machine revient avec un boot_id différent", () => {
|
|
expect(classifyReboot({ beforeBootId: "A", afterBootId: "B", wentDown: true, cameBack: true }).status).toBe("ok");
|
|
});
|
|
it("boot_id_unchanged si même boot_id", () => {
|
|
expect(classifyReboot({ beforeBootId: "A", afterBootId: "A", wentDown: true, cameBack: true }).status).toBe("boot_id_unchanged");
|
|
});
|
|
it("ssh_never_went_down si la coupure n'a pas été observée", () => {
|
|
expect(classifyReboot({ beforeBootId: "A", afterBootId: null, wentDown: false, cameBack: false }).status).toBe("ssh_never_went_down");
|
|
});
|
|
it("machine_did_not_return si coupure mais pas de retour", () => {
|
|
expect(classifyReboot({ beforeBootId: "A", afterBootId: null, wentDown: true, cameBack: false }).status).toBe("machine_did_not_return");
|
|
});
|
|
});
|