mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
test: make test-permission-sqlite-load-extension more robust
PR-URL: https://github.com/nodejs/node/pull/56295 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
This commit is contained in:
1 file changed
+8
-10
@@ -1,18 +1,16 @@
|
||||
'use strict';
|
||||
const common = require('../common');
|
||||
const assert = require('node:assert');
|
||||
const childProcess = require('child_process');
|
||||
|
||||
const code = `const sqlite = require('node:sqlite');
|
||||
const db = new sqlite.DatabaseSync(':memory:', { allowExtension: true });
|
||||
db.loadExtension('nonexistent');`.replace(/\n/g, ' ');
|
||||
|
||||
childProcess.exec(
|
||||
`${process.execPath} --permission -e "${code}"`,
|
||||
{},
|
||||
common.mustCall((err, _, stderr) => {
|
||||
assert.strictEqual(err.code, 1);
|
||||
assert.match(stderr, /Error: Cannot load SQLite extensions when the permission model is enabled/);
|
||||
assert.match(stderr, /code: 'ERR_LOAD_SQLITE_EXTENSION'/);
|
||||
})
|
||||
);
|
||||
common.spawnPromisified(
|
||||
process.execPath,
|
||||
['--permission', '--eval', code],
|
||||
).then(common.mustCall(({ code, stderr }) => {
|
||||
assert.match(stderr, /Error: Cannot load SQLite extensions when the permission model is enabled/);
|
||||
assert.match(stderr, /code: 'ERR_LOAD_SQLITE_EXTENSION'/);
|
||||
assert.strictEqual(code, 1);
|
||||
}));
|
||||
Reference in new issue
Block a user