8cce701715
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
31 lines
1.3 KiB
TypeScript
31 lines
1.3 KiB
TypeScript
// 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);
|
|
});
|
|
});
|