Skip to content

Commit 6442229

Browse files
araujoguiaduh95
authored andcommitted
sqlite: add some tests
PR-URL: #61410 Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 069f360 commit 6442229

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

‎test/parallel/test-sqlite-aggregate-function.mjs‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,19 @@ describe('DatabaseSync.prototype.aggregate()', () => {
6868
message: /The"options\.directOnly"argumentmustbeaboolean/,
6969
});
7070
});
71+
72+
test('throws if options.inverse is not a function',(t)=>{
73+
t.assert.throws(()=>{
74+
db.aggregate('sum',{
75+
start: 0,
76+
step: (acc,value)=>acc+value,
77+
inverse: 10
78+
});
79+
},{
80+
code: 'ERR_INVALID_ARG_TYPE',
81+
message: /The"options\.inverse"argumentmustbeafunction/,
82+
});
83+
});
7184
});
7285
});
7386

‎test/parallel/test-sqlite-template-tag.js‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ beforeEach(() => {
1515
sql.clear();
1616
});
1717

18+
test('throws error if database is not open',()=>{
19+
constdb=newDatabaseSync(':memory:',{open: false});
20+
21+
assert.throws(()=>{
22+
db.createTagStore(10);
23+
},{
24+
code: 'ERR_INVALID_STATE',
25+
message: 'database is not open'
26+
});
27+
});
28+
1829
test('sql.run inserts data',()=>{
1930
assert.strictEqual(sql.run`INSERT INTO foo (text) VALUES (${'bob'})`.changes,1);
2031
assert.strictEqual(sql.run`INSERT INTO foo (text) VALUES (${'mac'})`.changes,1);

0 commit comments

Comments
 (0)