Skip to content

Commit a2aed4d

Browse files
committed
test: convert more sqlite tests to in-memory
Extend the change to the named-parameter and statement suites, which only exercise SQL behavior, and to the throwaway databases in the main test file. Tests that depend on an on-disk or shared database keep using files: the constructor, open() and backup() cases, the timeout and cross-worker suites, and the WAL journal-mode PRAGMA. Refs: #64665 Signed-off-by: Paul Bouchon <mail@bitpshr.net>
1 parent 5fe0b0f commit a2aed4d

3 files changed

Lines changed: 46 additions & 63 deletions

File tree

test/parallel/test-sqlite-named-parameters.js

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
11
'use strict';
22
const { skipIfSQLiteMissing } = require('../common');
33
skipIfSQLiteMissing();
4-
const tmpdir = require('../common/tmpdir');
5-
const { join } = require('node:path');
64
const { DatabaseSync } = require('node:sqlite');
75
const { suite, test } = require('node:test');
8-
let cnt = 0;
9-
10-
tmpdir.refresh();
11-
12-
function nextDb() {
13-
return join(tmpdir.path, `database-${cnt++}.db`);
14-
}
156

167
suite('named parameters', () => {
178
test('throws on unknown named parameters', (t) => {
18-
const db = new DatabaseSync(nextDb());
9+
const db = new DatabaseSync(':memory:');
1910
t.after(() => { db.close(); });
2011
const setup = db.exec(
2112
'CREATE TABLE types(key INTEGER PRIMARY KEY, val INTEGER) STRICT;'
@@ -32,7 +23,7 @@ suite('named parameters', () => {
3223
});
3324

3425
test('bare named parameters are supported', (t) => {
35-
const db = new DatabaseSync(nextDb());
26+
const db = new DatabaseSync(':memory:');
3627
t.after(() => { db.close(); });
3728
const setup = db.exec(
3829
'CREATE TABLE data(key INTEGER PRIMARY KEY, val INTEGER) STRICT;'
@@ -47,7 +38,7 @@ suite('named parameters', () => {
4738
});
4839

4940
test('duplicate bare named parameters are supported', (t) => {
50-
const db = new DatabaseSync(nextDb());
41+
const db = new DatabaseSync(':memory:');
5142
t.after(() => { db.close(); });
5243
const setup = db.exec(
5344
'CREATE TABLE data(key INTEGER PRIMARY KEY, val INTEGER) STRICT;'
@@ -62,7 +53,7 @@ suite('named parameters', () => {
6253
});
6354

6455
test('bare named parameters throw on ambiguous names', (t) => {
65-
const db = new DatabaseSync(nextDb());
56+
const db = new DatabaseSync(':memory:');
6657
t.after(() => { db.close(); });
6758
const setup = db.exec(
6859
'CREATE TABLE types(key INTEGER PRIMARY KEY, val INTEGER) STRICT;'

0 commit comments

Comments
 (0)