feat: service machines (CRUD, test-connection, détection OS)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
// server/services/machines.test.ts
|
||||
import { describe, it, expect, vi } from "vitest";
|
||||
|
||||
// Mock all modules with side-effects at import time (DB, SSH, crypto)
|
||||
vi.mock("../db/client.js", () => ({ db: {}, schema: { machines: {} } }));
|
||||
vi.mock("../crypto/secrets.js", () => ({ encryptSecret: vi.fn(), decryptSecret: vi.fn() }));
|
||||
vi.mock("../env.js", () => ({ env: { requireMasterKey: vi.fn(), reportsDir: "/tmp" } }));
|
||||
vi.mock("../ssh/client.js", () => ({ runPlain: vi.fn() }));
|
||||
|
||||
import { parseOsRelease } from "./machines.js";
|
||||
|
||||
describe("parseOsRelease", () => {
|
||||
it("détecte Debian", () => {
|
||||
const r = parseOsRelease('ID=debian\nVERSION_ID="11"\nPRETTY_NAME="Debian 11"');
|
||||
expect(r).toEqual({ family: "debian", version: "11" });
|
||||
});
|
||||
it("détecte Ubuntu", () => {
|
||||
const r = parseOsRelease('ID=ubuntu\nVERSION_ID="22.04"');
|
||||
expect(r).toEqual({ family: "ubuntu", version: "22.04" });
|
||||
});
|
||||
it("retombe sur unknown", () => {
|
||||
expect(parseOsRelease("ID=arch").family).toBe("unknown");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user