mirror of
https://github.com/Effect-TS/effect.git
synced 2026-12-06 03:59:09 +08:00
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import { PgConnection } from "@effect/sql-pg"
|
|
import { assert, describe, it } from "@effect/vitest"
|
|
import { Effect, Redacted } from "effect"
|
|
|
|
describe("PgConnection config", () => {
|
|
it.effect("rejects sslmode=prefer in a URL", () =>
|
|
Effect.gen(function*() {
|
|
const error = yield* Effect.flip(PgConnection.make({
|
|
url: Redacted.make("postgres://user@localhost/db?sslmode=prefer")
|
|
}))
|
|
assert.strictEqual(error.reason._tag, "ConnectionError")
|
|
assert.include(error.reason.message, "sslmode")
|
|
}))
|
|
|
|
it.effect("rejects sslmode=allow in a URL", () =>
|
|
Effect.gen(function*() {
|
|
const error = yield* Effect.flip(PgConnection.make({
|
|
url: Redacted.make("postgresql://user@localhost/db?sslmode=allow")
|
|
}))
|
|
assert.strictEqual(error.reason._tag, "ConnectionError")
|
|
assert.include(error.reason.message, "sslmode")
|
|
}))
|
|
|
|
it.effect("rejects a non-postgres URL protocol", () =>
|
|
Effect.gen(function*() {
|
|
const error = yield* Effect.flip(PgConnection.make({
|
|
url: Redacted.make("mysql://user@localhost/db")
|
|
}))
|
|
assert.strictEqual(error.reason._tag, "ConnectionError")
|
|
}))
|
|
})
|