diff --git a/test/test.js b/test/test.js index 4efa4b7..5307698 100644 --- a/test/test.js +++ b/test/test.js @@ -16,6 +16,7 @@ describe("lbug", () => { importTest("Data types", "./test_data_type.js"); importTest("Query parameters", "./test_parameter.js"); importTest("Concurrent query execution", "./test_concurrency.js"); + importTest("Windows database paths", "./test_windows_path.js"); importTest("Version", "./test_version.js"); importTest("Synchronous API", "./test_sync_api.js"); }); diff --git a/test/test_windows_path.js b/test/test_windows_path.js new file mode 100644 index 0000000..bf34004 --- /dev/null +++ b/test/test_windows_path.js @@ -0,0 +1,38 @@ +if (process.platform === "win32" && !global.lbug) { + require("./common.js"); +} + +const itOnWindows = process.platform === "win32" ? it : it.skip; + +itOnWindows("opens an on-disk database with a native absolute Windows path", async function () { + const fs = require("fs"); + const path = require("path"); + + const testRoot = "C:\\adham\\lbug-test"; + fs.rmSync(testRoot, { recursive: true, force: true }); + fs.mkdirSync(testRoot, { recursive: true }); + const dbPath = path.join(testRoot, "db_wasm_iso.lbug"); + assert.include(dbPath, "\\"); + assert.match(dbPath, /^C:\\/); + + let db; + let conn; + try { + db = new lbug.Database(dbPath); + conn = new lbug.Connection(db); + await conn.query("CREATE NODE TABLE IF NOT EXISTS T(id STRING PRIMARY KEY)"); + await conn.query("CREATE (:T {id: 'one'})"); + const res = await conn.query("MATCH (t:T) RETURN t.id"); + const rows = await res.getAll(); + assert.deepEqual(rows, [{ "t.id": "one" }]); + res.close(); + } finally { + if (conn) { + await conn.close(); + } + if (db) { + await db.close(); + } + fs.rmSync(testRoot, { recursive: true, force: true }); + } +});