CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
db-driver.test.ts
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| 6f3ce18 | 1 | /** |
| 2 | * Tests for the dual-driver detection in src/db/index.ts. | |
| 3 | * Verifies which DATABASE_URL hosts route to Neon vs postgres.js. | |
| 4 | */ | |
| 5 | import { describe, expect, it } from "bun:test"; | |
| 6 | import { isNeonUrl } from "../db"; | |
| 7 | ||
| 8 | describe("isNeonUrl", () => { | |
| 9 | it("true for Neon US-East endpoint", () => { | |
| 10 | expect( | |
| 11 | isNeonUrl( | |
| 12 | "postgresql://user:pw@ep-cool-name-123.us-east-2.aws.neon.tech/db" | |
| 13 | ) | |
| 14 | ).toBe(true); | |
| 15 | }); | |
| 16 | ||
| 17 | it("true for Neon EU endpoint with sslmode", () => { | |
| 18 | expect( | |
| 19 | isNeonUrl( | |
| 20 | "postgres://u:p@ep-x.eu-central-1.aws.neon.tech/d?sslmode=require" | |
| 21 | ) | |
| 22 | ).toBe(true); | |
| 23 | }); | |
| 24 | ||
| 25 | it("true for bare neon.tech root", () => { | |
| 26 | expect(isNeonUrl("postgresql://u:p@neon.tech/db")).toBe(true); | |
| 27 | }); | |
| 28 | ||
| 29 | it("false for localhost", () => { | |
| 30 | expect(isNeonUrl("postgresql://u:p@127.0.0.1:5432/db")).toBe(false); | |
| 31 | expect(isNeonUrl("postgresql://u:p@localhost:5432/db")).toBe(false); | |
| 32 | }); | |
| 33 | ||
| 34 | it("false for RDS", () => { | |
| 35 | expect( | |
| 36 | isNeonUrl( | |
| 37 | "postgres://u:p@db.example.us-east-1.rds.amazonaws.com:5432/d" | |
| 38 | ) | |
| 39 | ).toBe(false); | |
| 40 | }); | |
| 41 | ||
| 42 | it("false for Supabase", () => { | |
| 43 | expect( | |
| 44 | isNeonUrl("postgres://u:p@db.abcd.supabase.co:5432/postgres") | |
| 45 | ).toBe(false); | |
| 46 | }); | |
| 47 | ||
| 48 | it("false for malformed URL (graceful fallback to TCP driver)", () => { | |
| 49 | expect(isNeonUrl("not-a-url")).toBe(false); | |
| 50 | expect(isNeonUrl("")).toBe(false); | |
| 51 | }); | |
| 52 | ||
| 53 | it("does not match domains that merely contain 'neon.tech' as a substring", () => { | |
| 54 | expect(isNeonUrl("postgres://u:p@evil-neon.tech.example.com/db")).toBe( | |
| 55 | false | |
| 56 | ); | |
| 57 | }); | |
| 58 | }); |