import { describe, it, expect } from "vitest"; import { analyzeRepositories } from "./aptRepositories.js"; const DEBIAN = [ "===SU:REPO_DEB===", "deb http://deb.debian.org/debian bookworm main contrib", "deb http://security.debian.org/debian-security bookworm-security main", "===SU:REPO_DEB822===", "===SU:EXIT=0===", ].join("\n"); const PROXMOX_ENTERPRISE = [ "===SU:REPO_DEB===", "deb http://ftp.debian.org/debian bookworm main contrib", "deb https://enterprise.proxmox.com/debian/pve bookworm pve-enterprise", "===SU:REPO_DEB822===", "===SU:EXIT=0===", ].join("\n"); describe("analyzeRepositories", () => { it("Debian : composants détectés et non-free-firmware absent → note", () => { const a = analyzeRepositories("debian", DEBIAN); expect(a.components).toContain("main"); expect(a.components).toContain("contrib"); expect(a.repos.length).toBeGreaterThanOrEqual(2); expect(a.notes.some((n) => /non-free-firmware/.test(n))).toBe(true); }); it("Proxmox : dépôt enterprise sans no-subscription → warning", () => { const a = analyzeRepositories("proxmox", PROXMOX_ENTERPRISE); expect(a.proxmox?.enterprise).toBe(true); expect(a.proxmox?.noSubscription).toBe(false); expect(a.warnings.some((w) => w.kind === "pve_enterprise_without_subscription")).toBe(true); }); it("Proxmox : aucun dépôt PVE → warning", () => { const a = analyzeRepositories("proxmox", DEBIAN); expect(a.warnings.some((w) => w.kind === "pve_repo_missing")).toBe(true); }); });