Skip to content

Commit 33cca0c

Browse files
committed
fixup!
1 parent c73eae8 commit 33cca0c

File tree

5 files changed

+29
-0
lines changed

5 files changed

+29
-0
lines changed
124 KB
Binary file not shown.

test/fixtures/sqlite/vec0.dll

161 KB
Binary file not shown.

test/fixtures/sqlite/vec0.so

115 KB
Binary file not shown.
123 KB
Binary file not shown.

test/parallel/test-sqlite.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const { spawnPromisified } = require('../common');
44
const tmpdir = require('../common/tmpdir');
55
const { existsSync } = require('node:fs');
66
const { join } = require('node:path');
7+
const os = require('node:os');
8+
const { path } = require('../common/fixtures');
79
const { DatabaseSync, StatementSync } = require('node:sqlite');
810
const { suite, test } = require('node:test');
911
let cnt = 0;
@@ -89,6 +91,33 @@ suite('DatabaseSync() constructor', () => {
8991
});
9092
});
9193

94+
suite('DatabaseSync.prototype.loadExtension()', () => {
95+
test('loads an extension', (t) => {
96+
const dbPath = nextDb();
97+
const db = new DatabaseSync(dbPath, { allowLoadExtension: true });
98+
const supportedPlatforms = [
99+
["macos","x86_64"],
100+
["windows","x86_64"],
101+
["linux","x86_64"],
102+
["macos","aarch64"]
103+
];
104+
function validPlatform(platform, arch) {
105+
return (
106+
supportedPlatforms.find(([p, a]) => platform == p && arch === a) !== null
107+
);
108+
}
109+
const platform = os.platform();
110+
const arch = os.arch();
111+
if (!validPlatform(platform, arch)) {
112+
t.skip();
113+
return;
114+
}
115+
const ext = platform === 'win32' ? 'dll' : platform === 'darwin' ? process.arch === 'arm64' ? '.aarch64.dylib' : '.x86_64.dylib' : 'so';
116+
const extension = path('sqlite', `vec0${ext}`)
117+
t.assert.strictEqual(db.loadExtension(extension), undefined);
118+
});
119+
});
120+
92121
suite('DatabaseSync.prototype.open()', () => {
93122
test('opens a database connection', (t) => {
94123
const dbPath = nextDb();

0 commit comments

Comments
 (0)