Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

848 B
Raw Blame
import { afterEach, describe, expect, it, vi } from "vite-plus/test";
import { probeRedis } from "./probe-redis";

const subscriber = vi.hoisted(() => ({ status: "ready" }));
vi.mock("../../redis", () => ({
  isRedisConfigured: () => true,
  resolveRedisMode: () => ({ mode: "standalone" }),
  getRedisPub: () => ({ ping: async () => "PONG" }),
  getRedisSub: () => subscriber,
}));

describe("probeRedis", () => {
  afterEach(() => {
    subscriber.status = "ready";
  });

  it("reports a disconnected subscriber despite a healthy publisher", async () => {
    subscriber.status = "reconnecting";
    await expect(probeRedis(100)).resolves.toMatchObject({
      status: "down",
      errorCode: "SUBSCRIBER_NOT_READY",
    });
    subscriber.status = "ready";
    await expect(probeRedis(100)).resolves.toMatchObject({ status: "ok" });
  });
});