|
1 | 1 | import { describe, expect, it, vi } from "vitest"; |
2 | 2 | // @testcontainers/postgresql resolves because it is declared in apps/webapp/package.json. |
3 | 3 | import { PostgreSqlContainer } from "@testcontainers/postgresql"; |
4 | | -import { computeSplitEnabled } from "~/v3/runOpsMigration/splitMode.server"; |
| 4 | +import { |
| 5 | + computeSplitEnabled, |
| 6 | + assertSplitRealtimeInterlock, |
| 7 | +} from "~/v3/runOpsMigration/splitMode.server"; |
5 | 8 | import { probeDistinctDatabases } from "~/v3/runOpsMigration/distinctDbSentinel.server"; |
6 | 9 |
|
7 | 10 | describe("computeSplitEnabled (pure)", () => { |
@@ -58,6 +61,29 @@ describe("computeSplitEnabled (pure)", () => { |
58 | 61 | }); |
59 | 62 | }); |
60 | 63 |
|
| 64 | +describe("assertSplitRealtimeInterlock (pure)", () => { |
| 65 | + it("throws when split is on but the native realtime backend is off", () => { |
| 66 | + expect(() => |
| 67 | + assertSplitRealtimeInterlock({ splitEnabled: true, nativeRealtimeEnabled: false }) |
| 68 | + ).toThrowError(/native realtime backend|REALTIME_BACKEND_NATIVE_ENABLED/i); |
| 69 | + }); |
| 70 | + |
| 71 | + it("does not throw when split is on and the native realtime backend is on", () => { |
| 72 | + expect(() => |
| 73 | + assertSplitRealtimeInterlock({ splitEnabled: true, nativeRealtimeEnabled: true }) |
| 74 | + ).not.toThrow(); |
| 75 | + }); |
| 76 | + |
| 77 | + it("does not throw when split is off, regardless of the native realtime backend", () => { |
| 78 | + expect(() => |
| 79 | + assertSplitRealtimeInterlock({ splitEnabled: false, nativeRealtimeEnabled: false }) |
| 80 | + ).not.toThrow(); |
| 81 | + expect(() => |
| 82 | + assertSplitRealtimeInterlock({ splitEnabled: false, nativeRealtimeEnabled: true }) |
| 83 | + ).not.toThrow(); |
| 84 | + }); |
| 85 | +}); |
| 86 | + |
61 | 87 | describe("distinct-DB sentinel (real Postgres)", () => { |
62 | 88 | it("reports NOT distinct when both URLs hit the same physical cluster", async () => { |
63 | 89 | const pg = await new PostgreSqlContainer("docker.io/postgres:14").start(); |
|
0 commit comments