import { describe, expect, it } from "vitest";
import { createInspectEnvTool } from "./inspect-env.js";

describe("inspect-env tool", () => {
  it("reports allowlisted metadata without secret values", () => {
    const previousKey = process.env.OPENAI_API_KEY;
    const previousModel = process.env.OPENAI_MODEL;
    process.env.OPENAI_API_KEY = "sk-test-secret";
    process.env.OPENAI_MODEL = "glm-5";

    try {
      const output = createInspectEnvTool().execute({}, undefined as never);

      expect(output).toContain("OPENAI_API_KEY=[set]");
      expect(output).toContain("OPENAI_MODEL=glm-5");
      expect(output).not.toContain("sk-test-secret");
    } finally {
      if (previousKey === undefined) delete process.env.OPENAI_API_KEY;
      else process.env.OPENAI_API_KEY = previousKey;
      if (previousModel === undefined) delete process.env.OPENAI_MODEL;
      else process.env.OPENAI_MODEL = previousModel;
    }
  });
});
