feat: parser sortie apt-get -s full-upgrade -> AptPackage[]

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-04 21:03:52 +02:00
parent dc0ef1b7e9
commit 8cce701715
3 changed files with 67 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
// server/services/aptParse.test.ts
import { describe, it, expect } from "vitest";
import { readFileSync } from "node:fs";
import { fileURLToPath } from "node:url";
import { parseAptSimulate, parseRebootRequired } from "./aptParse.js";
const raw = readFileSync(fileURLToPath(new URL("./__fixtures__/apt-simulate.txt", import.meta.url)), "utf8");
describe("parseAptSimulate", () => {
it("extrait les paquets upgradables avec versions et origine", () => {
const pkgs = parseAptSimulate(raw);
expect(pkgs).toEqual([
{ name: "libc6", currentVersion: "2.31-13", targetVersion: "2.31-13+deb11u5", origin: "Debian:11.6/stable" },
{ name: "pve-manager", currentVersion: "8.4-1", targetVersion: "8.4-3", origin: "Proxmox VE:8.x" },
{ name: "newpkg", currentVersion: null, targetVersion: "1.0.0", origin: "Debian:11.6/stable" },
]);
});
it("retourne un tableau vide quand aucun Inst", () => {
expect(parseAptSimulate("Reading package lists...\nDone")).toEqual([]);
});
});
describe("parseRebootRequired", () => {
it("détecte le marqueur REBOOT_REQUIRED=1", () => {
expect(parseRebootRequired("REBOOT_REQUIRED=1")).toBe(true);
expect(parseRebootRequired("REBOOT_REQUIRED=0")).toBe(false);
expect(parseRebootRequired("rien")).toBe(false);
});
});