Skip to content

Commit

Permalink
test: make test-permission-sqlite-load-extension more robust
Browse files Browse the repository at this point in the history
PR-URL: #56295
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Xuguang Mei <[email protected]>
  • Loading branch information
aduh95 authored Dec 19, 2024
1 parent fd8de67 commit ec6e6b5
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions test/parallel/test-permission-sqlite-load-extension.js
Original file line number Diff line number Diff line change
@@ -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);
}));

0 comments on commit ec6e6b5

Please sign in to comment.