Skip to content

Commit 1a83655

Browse files
committed
few misc specs
1 parent caf32d6 commit 1a83655

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

spec/postgres_spec.moon

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,11 @@ TESTS = {
484484
[[INSERT INTO "cats" ("profile") VALUES ('blue') ON CONFLICT DO NOTHING RETURNING *]]
485485
}
486486

487+
{
488+
-> db.insert "cats", { name: "test" }, on_conflict: "do_nothing", returning: {"id", "name"}
489+
[[INSERT INTO "cats" ("name") VALUES ('test') ON CONFLICT DO NOTHING RETURNING "id", "name"]]
490+
}
491+
487492

488493
-- lapis.db.postgres.schema
489494

@@ -1116,6 +1121,17 @@ describe "lapis.db.postgres", ->
11161121
opts: { application_name: "anonymous" }
11171122
}, conn
11181123

1124+
it "handles connection failure", ->
1125+
import Postgres from require "pgmoon"
1126+
1127+
-- Override the connect stub to simulate failure
1128+
stub(Postgres.__base, "connect").invokes =>
1129+
false, "connection refused"
1130+
1131+
assert.has_error(
1132+
-> require("lapis.db.postgres").query "SELECT 1"
1133+
"postgres (default) failed to connect: connection refused"
1134+
)
11191135

11201136

11211137
describe "in ngx", ->

0 commit comments

Comments
 (0)