Track HiveGrid Cloud planning reference

This commit is contained in:
david committed 2026-06-26 20:48:01 +02:00
1 parent b3d5ea6764
commit e341c5938a
5784 files changed
+1104929 -3

No files matched your search

@@ -0,0 +1,52 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
vi.mock("~/utils/db.server", () => ({
db: {
appConfiguration: {
count: vi.fn(),
},
},
}));
describe("web readyz route", () => {
beforeEach(async () => {
const { db } = await import("~/utils/db.server");
vi.mocked(db.appConfiguration.count).mockReset();
});
it("returns readiness when the database count succeeds", async () => {
const { db } = await import("~/utils/db.server");
vi.mocked(db.appConfiguration.count).mockResolvedValueOnce(1);
const { loader } = await import("./readyz");
const response = await loader();
const body = await response.json();
expect(response.status).toBe(200);
expect(body).toEqual({ status: "ready", service: "web" });
expect(db.appConfiguration.count).toHaveBeenCalledTimes(1);
});
it("returns a redacted readiness failure when the database count throws", async () => {
const { db } = await import("~/utils/db.server");
vi.mocked(db.appConfiguration.count).mockRejectedValueOnce(
new Error("postgres://user:password@example.internal/app?token=secret"),
);
const { loader } = await import("./readyz");
const response = await loader();
const body = await response.json();
const text = JSON.stringify(body);
expect(response.status).toBe(503);
expect(body).toEqual({
status: "not_ready",
service: "web",
error: "database_unavailable",
});
expect(text).not.toContain("postgres://");
expect(text).not.toContain("password");
expect(text).not.toContain("secret");
expect(db.appConfiguration.count).toHaveBeenCalledTimes(1);
});
});