Skip to content

Commit aa8f961

Browse files
test: remove sqlite Statement#iterator tests
Iteration support probably won't ever be added to the async API, therefore remove the currently skipped tests for it.
1 parent bc3b81c commit aa8f961

File tree

1 file changed

+0
-88
lines changed

1 file changed

+0
-88
lines changed

test/parallel/test-sqlite-statement-async.js

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -107,94 +107,6 @@ suite('Statement.prototype.all()', () => {
107107
});
108108
});
109109

110-
suite.skip('Statement.prototype.iterate()', () => {
111-
test('executes a query and returns an empty iterator on no results', async (t) => {
112-
const db = new Database(nextDb());
113-
t.after(() => { db.close(); });
114-
const stmt = db.prepare('CREATE TABLE storage(key TEXT, val TEXT)');
115-
const iter = stmt.iterate();
116-
t.assert.strictEqual(iter instanceof globalThis.Iterator, true);
117-
t.assert.ok(iter[Symbol.iterator]);
118-
t.assert.deepStrictEqual(iter.toArray(), []);
119-
});
120-
121-
test('executes a query and returns all results', async (t) => {
122-
const db = new Database(nextDb());
123-
t.after(() => { db.close(); });
124-
let stmt = db.prepare('CREATE TABLE storage(key TEXT, val TEXT)');
125-
t.assert.deepStrictEqual(await stmt.run(), { changes: 0, lastInsertRowid: 0 });
126-
stmt = db.prepare('INSERT INTO storage (key, val) VALUES (?, ?)');
127-
t.assert.deepStrictEqual(
128-
await stmt.run('key1', 'val1'),
129-
{ changes: 1, lastInsertRowid: 1 },
130-
);
131-
t.assert.deepStrictEqual(
132-
await stmt.run('key2', 'val2'),
133-
{ changes: 1, lastInsertRowid: 2 },
134-
);
135-
136-
const items = [
137-
{ __proto__: null, key: 'key1', val: 'val1' },
138-
{ __proto__: null, key: 'key2', val: 'val2' },
139-
];
140-
141-
stmt = db.prepare('SELECT * FROM storage ORDER BY key');
142-
t.assert.deepStrictEqual(stmt.iterate().toArray(), items);
143-
144-
const itemsLoop = items.slice();
145-
for (const item of stmt.iterate()) {
146-
t.assert.deepStrictEqual(item, itemsLoop.shift());
147-
}
148-
});
149-
150-
test('iterator keeps the prepared statement from being collected', async (t) => {
151-
const db = new Database(':memory:');
152-
await db.exec(`
153-
CREATE TABLE test(key TEXT, val TEXT);
154-
INSERT INTO test (key, val) VALUES ('key1', 'val1');
155-
INSERT INTO test (key, val) VALUES ('key2', 'val2');
156-
`);
157-
// Do not keep an explicit reference to the prepared statement.
158-
const iterator = db.prepare('SELECT * FROM test').iterate();
159-
const results = [];
160-
161-
global.gc();
162-
163-
for (const item of iterator) {
164-
results.push(item);
165-
}
166-
167-
t.assert.deepStrictEqual(results, [
168-
{ __proto__: null, key: 'key1', val: 'val1' },
169-
{ __proto__: null, key: 'key2', val: 'val2' },
170-
]);
171-
});
172-
173-
test('iterator can be exited early', async (t) => {
174-
const db = new Database(':memory:');
175-
await db.exec(`
176-
CREATE TABLE test(key TEXT, val TEXT);
177-
INSERT INTO test (key, val) VALUES ('key1', 'val1');
178-
INSERT INTO test (key, val) VALUES ('key2', 'val2');
179-
`);
180-
const iterator = db.prepare('SELECT * FROM test').iterate();
181-
const results = [];
182-
183-
for (const item of iterator) {
184-
results.push(item);
185-
break;
186-
}
187-
188-
t.assert.deepStrictEqual(results, [
189-
{ __proto__: null, key: 'key1', val: 'val1' },
190-
]);
191-
t.assert.deepStrictEqual(
192-
iterator.next(),
193-
{ __proto__: null, done: true, value: null },
194-
);
195-
});
196-
});
197-
198110
suite('Statement.prototype.run()', () => {
199111
test('executes a query and returns change metadata', async (t) => {
200112
const db = new Database(nextDb());

0 commit comments

Comments
 (0)