import { expect, test } from "bun:test";
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import path from "node:path";

import { hwpodNativeServicesStatus } from "./hwpod-native-service.ts";

test("HWPOD aggregate status reports API, worker, and Web together", async () => {
  const cwd = await mkdtemp(path.join(tmpdir(), "hwpod-native-status-"));
  try {
    const result = await hwpodNativeServicesStatus({ cwd, env: { HWPOD_NATIVE_SERVICE_STATE_DIR: ".state/services" } });
    expect(result).toMatchObject({
      ok: false,
      status: "stopped",
      summary: { total: 3, running: 0, unavailable: 3 },
      services: {
        api: { service: "api", status: "stopped" },
        worker: { service: "worker", status: "stopped" },
        web: { service: "web", status: "stopped" },
      },
    });
  } finally {
    await rm(cwd, { recursive: true, force: true });
  }
});
