| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 5cac7c2 commit 74a3e91
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,22 +1,13 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const { skipIfSQLiteMissing } = require('../common'); | |
| 3 | 3 | skipIfSQLiteMissing(); | |
| 4 | - const tmpdir = require('../common/tmpdir'); | ||
| 5 | - const { join } = require('node:path'); | ||
| 6 | 4 | const { DatabaseSync } = require('node:sqlite'); | |
| 7 | 5 | 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 | - } | ||
| 15 | 6 | ||
| 16 | 7 | suite('data binding and mapping', () => { | |
| 17 | 8 | test('supported data types', (t) => { | |
| 18 | 9 | const u8a = new TextEncoder().encode('a☃b☃c'); | |
| 19 | - const db = new DatabaseSync(nextDb()); | ||
| 10 | + const db = new DatabaseSync(':memory:'); | ||
| 20 | 11 | t.after(() => { db.close(); }); | |
| 21 | 12 | const setup = db.exec(` | |
| 22 | 13 | CREATE TABLE types( | |
@@ -83,7 +74,7 @@ suite('data binding and mapping', () => { | |||
| 83 | 74 | }); | |
| 84 | 75 | ||
| 85 | 76 | test('large strings are bound correctly', (t) => { | |
| 86 | - const db = new DatabaseSync(nextDb()); | ||
| 77 | + const db = new DatabaseSync(':memory:'); | ||
| 87 | 78 | t.after(() => { db.close(); }); | |
| 88 | 79 | const setup = db.exec( | |
| 89 | 80 | 'CREATE TABLE data(key INTEGER PRIMARY KEY, text TEXT) STRICT;' | |
@@ -118,7 +109,7 @@ suite('data binding and mapping', () => { | |||
| 118 | 109 | }); | |
| 119 | 110 | ||
| 120 | 111 | test('unsupported data types', (t) => { | |
| 121 | - const db = new DatabaseSync(nextDb()); | ||
| 112 | + const db = new DatabaseSync(':memory:'); | ||
| 122 | 113 | t.after(() => { db.close(); }); | |
| 123 | 114 | const setup = db.exec( | |
| 124 | 115 | 'CREATE TABLE types(key INTEGER PRIMARY KEY, val INTEGER) STRICT;' | |
@@ -153,7 +144,7 @@ suite('data binding and mapping', () => { | |||
| 153 | 144 | ||
| 154 | 145 | test('throws when binding a BigInt that is too large', (t) => { | |
| 155 | 146 | const max = 9223372036854775807n; // Largest 64-bit signed integer value. | |
| 156 | - const db = new DatabaseSync(nextDb()); | ||
| 147 | + const db = new DatabaseSync(':memory:'); | ||
| 157 | 148 | t.after(() => { db.close(); }); | |
| 158 | 149 | const setup = db.exec( | |
| 159 | 150 | 'CREATE TABLE types(key INTEGER PRIMARY KEY, val INTEGER) STRICT;' | |
@@ -173,7 +164,7 @@ suite('data binding and mapping', () => { | |||
| 173 | 164 | }); | |
| 174 | 165 | ||
| 175 | 166 | test('statements are unbound on each call', (t) => { | |
| 176 | - const db = new DatabaseSync(nextDb()); | ||
| 167 | + const db = new DatabaseSync(':memory:'); | ||
| 177 | 168 | t.after(() => { db.close(); }); | |
| 178 | 169 | const setup = db.exec( | |
| 179 | 170 | 'CREATE TABLE data(key INTEGER PRIMARY KEY, val INTEGER) STRICT;' | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,21 +1,12 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const { skipIfSQLiteMissing } = require('../common'); | |
| 3 | 3 | skipIfSQLiteMissing(); | |
| 4 | - const tmpdir = require('../common/tmpdir'); | ||
| 5 | - const { join } = require('node:path'); | ||
| 6 | 4 | const { DatabaseSync } = require('node:sqlite'); | |
| 7 | 5 | 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 | - } | ||
| 15 | 6 | ||
| 16 | 7 | suite('named parameters', () => { | |
| 17 | 8 | test('throws on unknown named parameters', (t) => { | |
| 18 | - const db = new DatabaseSync(nextDb()); | ||
| 9 | + const db = new DatabaseSync(':memory:'); | ||
| 19 | 10 | t.after(() => { db.close(); }); | |
| 20 | 11 | const setup = db.exec( | |
| 21 | 12 | 'CREATE TABLE types(key INTEGER PRIMARY KEY, val INTEGER) STRICT;' | |
@@ -32,7 +23,7 @@ suite('named parameters', () => { | |||
| 32 | 23 | }); | |
| 33 | 24 | ||
| 34 | 25 | test('bare named parameters are supported', (t) => { | |
| 35 | - const db = new DatabaseSync(nextDb()); | ||
| 26 | + const db = new DatabaseSync(':memory:'); | ||
| 36 | 27 | t.after(() => { db.close(); }); | |
| 37 | 28 | const setup = db.exec( | |
| 38 | 29 | 'CREATE TABLE data(key INTEGER PRIMARY KEY, val INTEGER) STRICT;' | |
@@ -47,7 +38,7 @@ suite('named parameters', () => { | |||
| 47 | 38 | }); | |
| 48 | 39 | ||
| 49 | 40 | test('duplicate bare named parameters are supported', (t) => { | |
| 50 | - const db = new DatabaseSync(nextDb()); | ||
| 41 | + const db = new DatabaseSync(':memory:'); | ||
| 51 | 42 | t.after(() => { db.close(); }); | |
| 52 | 43 | const setup = db.exec( | |
| 53 | 44 | 'CREATE TABLE data(key INTEGER PRIMARY KEY, val INTEGER) STRICT;' | |
@@ -62,7 +53,7 @@ suite('named parameters', () => { | |||
| 62 | 53 | }); | |
| 63 | 54 | ||
| 64 | 55 | test('bare named parameters throw on ambiguous names', (t) => { | |
| 65 | - const db = new DatabaseSync(nextDb()); | ||
| 56 | + const db = new DatabaseSync(':memory:'); | ||
| 66 | 57 | t.after(() => { db.close(); }); | |
| 67 | 58 | const setup = db.exec( | |
| 68 | 59 | 'CREATE TABLE types(key INTEGER PRIMARY KEY, val INTEGER) STRICT;' | |
| Back | FazBrowse Home | New Git URL |
0 commit comments