// src/types.test.ts - NEW FILE
import { describe, expect, it } from "vitest";
import type { ServiceContainerHealth } from "./services/container.js";
import type { HostConfig, ServiceHealth } from "./types.js";
describe("HostConfig", () => {
it("should support optional composeSearchPaths field", () => {
const config: HostConfig = {
name: "test",
host: "localhost",
protocol: "ssh",
composeSearchPaths: ["/opt/stacks", "/srv/docker"],
};
expect(config.composeSearchPaths).toEqual(["/opt/stacks", "/srv/docker"]);
});
it("should work without composeSearchPaths", () => {
const config: HostConfig = {
name: "test",
host: "localhost",
protocol: "ssh",
};
expect(config.composeSearchPaths).toBeUndefined();
});
});
describe("ServiceHealth vs ServiceContainerHealth", () => {
it("should have distinct types for Docker health vs DI health", () => {
// Docker service health (from types.ts)
const dockerHealth: ServiceHealth = {
name: "nginx",
host: "docker-01",
containerId: "abc123",
state: "running",
uptime: "3 days",
restartCount: 0,
healthStatus: "healthy",
lastHealthCheck: new Date().toISOString(),
};
// DI container health (from container.ts) - different shape
const containerHealth: ServiceContainerHealth = {
name: "SSHConnectionPool",
healthy: true,
responseTime: 42,
};
expect(dockerHealth.name).toBe("nginx");
expect(containerHealth.name).toBe("SSHConnectionPool");
// These are distinct types with no collision
expect("containerId" in dockerHealth).toBe(true);
expect("healthy" in containerHealth).toBe(true);
});
});