Files
system_update/server/services/aptRepositories.test.ts
T
gilles d1b0290e3b feat(apt): analyse des dépôts APT (lecture seule) (tâche 4)
- template repositories (deb lines + deb822), non destructif
- analyzeRepositories (TDD) : composants, repos, détection Proxmox
  enterprise/no-subscription, warnings (pve_enterprise_without_subscription,
  pve_repo_missing) + notes Debian/Ubuntu composants manquants
- route POST /machines/:id/apt-repositories ; api analyzeRepositories
- popup config : bloc « Dépôts APT » (composants + warnings + notes)

Analyse uniquement (modification = action validée séparée, future). tsc 0 · 113 tests · build OK.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-06 18:41:11 +02:00

41 lines
1.5 KiB
TypeScript

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);
});
});