import { jest } from "@jest/globals"; const query = jest.fn(); const release = jest.fn(async () => {}); jest.unstable_mockModule("../../db/index.js", () => ({ getPool: async () => ({ query, release }) })); const { getStorage } = await import("./storage.js"); beforeEach(() => { query.mockReset(); release.mockClear(); }); describe("getStorage (core + audit in one query)", () => { it("runs a single query and shapes on-disk/logical core/audit/total byte totals", async () => { query.mockResolvedValue({ rows: [{ core_on_disk: "100", core_logical: "120", audit_on_disk: "50", audit_logical: "60" }], }); const out = await getStorage(7); expect(query).toHaveBeenCalledTimes(1); // combined round-trip expect(query.mock.calls[0][1]).toEqual([7]); expect(out).toEqual({ onDisk: { core: 100, audit: 50, total: 150 }, logical: { core: 120, audit: 60, total: 180 }, }); expect(release).toHaveBeenCalledTimes(1); }); });