2af8e74079
- 4 tables Docker (settings/compose_roots/compose_stacks/stack_services)
+ migration 0004 (timestamps journal monotones)
- templates docker/scan-compose + inspect-compose ; renderTemplate bascule
sur délimiteurs <% %> pour les templates docker/ afin de préserver les
Go-templates {{.ID}} intacts
- dockerScan: parseDockerScan (TDD) + scanDockerStacks (persiste stacks
candidats, complète la détection par labels)
- action docker_scan branchée dans execute (route dédiée, archivage report/log)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
37 lines
1.5 KiB
TypeScript
37 lines
1.5 KiB
TypeScript
// server/templates/render.test.ts
|
|
import { describe, it, expect } from "vitest";
|
|
import { renderTemplate } from "./render.js";
|
|
|
|
describe("renderTemplate", () => {
|
|
it("rend check.sh.tpl sans proxy", () => {
|
|
const out = renderTemplate("apt/check.sh.tpl", { aptProxy: null });
|
|
expect(out).toContain("apt-get update -qq");
|
|
expect(out).toContain("===SU:SIMULATE===");
|
|
expect(out).not.toContain("http_proxy");
|
|
});
|
|
|
|
it("injecte le proxy quand fourni", () => {
|
|
const out = renderTemplate("apt/check.sh.tpl", { aptProxy: "http://cache:3142" });
|
|
expect(out).toContain('http_proxy="http://cache:3142"');
|
|
});
|
|
|
|
it("rend update-analyze.sh.tpl avec les sections attendues", () => {
|
|
const out = renderTemplate("apt/update-analyze.sh.tpl", { aptProxy: null });
|
|
expect(out).toContain("===SU:APT_SIM_DISTUPGRADE===");
|
|
expect(out).toContain("apt-mark showhold");
|
|
});
|
|
|
|
it("rend les variables Docker en <% %> sans toucher aux Go-templates {{...}}", () => {
|
|
const out = renderTemplate("docker/scan-compose.sh.tpl", { composeRoots: "/opt/stacks", composeScanDepth: 3 });
|
|
expect(out).toContain("/opt/stacks");
|
|
expect(out).toContain("{{.ID}}"); // Go-template Docker resté littéral
|
|
expect(out).not.toContain("<%composeRoots%>");
|
|
});
|
|
|
|
it("rétro-compat : les templates APT ({{ }}) restent fonctionnels", () => {
|
|
const out = renderTemplate("apt/check.sh.tpl", { aptProxy: "http://proxy:3142" });
|
|
expect(out).toContain("http://proxy:3142");
|
|
expect(out).not.toContain("{{");
|
|
});
|
|
});
|