From 349224869751c9d74540d5de75bf0681c69dd45d Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Sun, 22 Jan 2023 19:09:52 -0800 Subject: Fixes #1366 --- test/bun.js/sqlite.test.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'test/bun.js/sqlite.test.js') diff --git a/test/bun.js/sqlite.test.js b/test/bun.js/sqlite.test.js index e5f83fe4d..f78d3b481 100644 --- a/test/bun.js/sqlite.test.js +++ b/test/bun.js/sqlite.test.js @@ -1,6 +1,9 @@ import { expect, it, describe } from "bun:test"; import { Database, constants } from "bun:sqlite"; -import { existsSync, fstat, writeFileSync } from "fs"; +import { existsSync, fstat, realpathSync, rmSync, writeFileSync } from "fs"; +import { spawnSync } from "bun"; +import { bunExe } from "bunExe"; +import { tmpdir } from "os"; var encode = (text) => new TextEncoder().encode(text); it("Database.open", () => { @@ -55,6 +58,27 @@ it("Database.open", () => { new Database().close(); }); +it("upsert cross-process, see #1366", () => { + const dir = realpathSync(tmpdir()) + "/"; + const { exitCode } = spawnSync( + [bunExe(), import.meta.dir + "/sqlite-cross-process.js"], + { + env: { + SQLITE_DIR: dir, + }, + stderr: "inherit", + }, + ); + expect(exitCode).toBe(0); + + const db2 = Database.open(dir + "get-persist.sqlite"); + + expect(db2.query(`SELECT id FROM examples`).all()).toEqual([ + { id: "hello" }, + { id: "world" }, + ]); +}); + it("creates", () => { const db = Database.open(":memory:"); db.exec( -- cgit v1.2.3