Skip to content

Commit 3867c79

Browse files
author
Daniele Briggi
committed
fix(tests): skip stress tests
1 parent d1819ba commit 3867c79

File tree

4 files changed

+43
-28
lines changed

4 files changed

+43
-28
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sqlitecloud/drivers",
3-
"version": "1.0.399",
3+
"version": "1.0.400",
44
"description": "SQLiteCloud drivers for Typescript/Javascript in edge, web and node clients",
55
"main": "./lib/index.js",
66
"types": "./lib/index.d.ts",

test/1brc.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ async function createDatabaseAsync(numberOfRows: number): Promise<{ connection:
7878
const createSql = `UNUSE DATABASE; CREATE DATABASE ${database}; USE DATABASE ${database};`
7979
const createResults = await sendCommandsAsync(connection, createSql)
8080
expect(createResults).toBe('OK')
81-
return { database, connection }
81+
return { connection, database }
8282
}
8383

8484
async function destroyDatabaseAsync(connection: SQLiteCloudConnection, database: string) {
@@ -207,7 +207,7 @@ async function testChallenge(numberOfRows: number, insertChunks = BRC_INSERT_CHU
207207
throw error
208208
}
209209
} finally {
210-
// await destroyDatabaseAsync(connection, database)
210+
await destroyDatabaseAsync(connection, database)
211211
connection?.close()
212212
}
213213
}

test/database.test.ts

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,17 @@
22
* database.test.ts - test driver api
33
*/
44

5-
import { SQLiteCloudRowset, SQLiteCloudRow, SQLiteCloudError, sanitizeSQLiteIdentifier } from '../src/index'
5+
import { describe, expect, it } from '@jest/globals'
6+
import { RowCountCallback } from '../src/drivers/types'
7+
import { SQLiteCloudError, SQLiteCloudRow, SQLiteCloudRowset, sanitizeSQLiteIdentifier } from '../src/index'
68
import {
9+
LONG_TIMEOUT,
10+
getChinookDatabase,
711
getTestingDatabase,
812
getTestingDatabaseAsync,
9-
getChinookDatabase,
1013
removeDatabase,
11-
removeDatabaseAsync,
12-
LONG_TIMEOUT,
13-
getChinookWebsocketConnection
14+
removeDatabaseAsync
1415
} from './shared'
15-
import { RowCountCallback } from '../src/drivers/types'
16-
import { expect, describe, it } from '@jest/globals'
17-
import { Database } from 'sqlite3'
1816

1917
//
2018
// utility methods to setup and destroy temporary test databases
@@ -55,6 +53,7 @@ describe('Database.run', () => {
5553
expect(error).toBeNull()
5654
database.run(updateSql, plainCallbackNotALambda)
5755
})
56+
removeDatabase(database)
5857
},
5958
LONG_TIMEOUT
6059
)
@@ -114,6 +113,7 @@ describe('Database.run', () => {
114113
expect(error).toBeNull()
115114
database.run(insertSql, plainCallbackNotALambdaOne)
116115
})
116+
removeDatabase(database)
117117
},
118118
LONG_TIMEOUT
119119
)
@@ -317,7 +317,7 @@ describe('Database.sql (async)', () => {
317317
const results = await database.sql('SELECT * FROM people WHERE name = ?', 'Emma Johnson')
318318
expect(results).toHaveLength(1)
319319
} finally {
320-
database?.close()
320+
await removeDatabaseAsync(database)
321321
}
322322
})
323323

@@ -337,7 +337,7 @@ describe('Database.sql (async)', () => {
337337
hobby: 'Collecting clouds'
338338
})
339339
} finally {
340-
database?.close()
340+
await removeDatabaseAsync(database)
341341
}
342342
})
343343

@@ -487,30 +487,45 @@ describe('Database.sql (async)', () => {
487487

488488
describe('should sanitize identifiers', () => {
489489
it('should sanitize database name and run the query', async () => {
490-
const database = await getTestingDatabaseAsync()
490+
let database
491+
try {
492+
database = await getTestingDatabaseAsync()
491493

492-
const databaseName = sanitizeSQLiteIdentifier(database.getConfiguration().database || '')
493-
await expect(database.sql(`USE DATABASE ${databaseName}`)).resolves.toBe('OK')
494+
const databaseName = sanitizeSQLiteIdentifier(database.getConfiguration().database || '')
495+
await expect(database.sql(`USE DATABASE ${databaseName}`)).resolves.toBe('OK')
496+
} finally {
497+
await removeDatabaseAsync(database)
498+
}
494499
})
495500

496501
it('should sanitize table name and run the query', async () => {
497-
const database = await getTestingDatabaseAsync()
502+
let database
503+
try {
504+
database = await getTestingDatabaseAsync()
498505

499-
const table = sanitizeSQLiteIdentifier('people')
500-
await expect(database.sql(`SELECT id FROM ${table} LIMIT 1`)).resolves.toMatchObject([{ id: 1 }])
506+
const table = sanitizeSQLiteIdentifier('people')
507+
await expect(database.sql(`SELECT id FROM ${table} LIMIT 1`)).resolves.toMatchObject([{ id: 1 }])
508+
} finally {
509+
await removeDatabaseAsync(database)
510+
}
501511
})
502512

503513
it('should sanitize SQL Injection as table name', async () => {
504-
const database = await getTestingDatabaseAsync()
505-
const databaseName = database.getConfiguration().database
514+
let database
515+
try {
516+
database = await getTestingDatabaseAsync()
517+
const databaseName = database.getConfiguration().database
506518

507-
const sanitizedDBName = sanitizeSQLiteIdentifier(`${databaseName}; SELECT * FROM people; -- `)
508-
await expect(database.sql(`USE DATABASE ${sanitizedDBName}`)).rejects.toThrow(
509-
`Database name contains invalid characters (${databaseName}; SELECT * FROM people; --).`
510-
)
519+
const sanitizedDBName = sanitizeSQLiteIdentifier(`${databaseName}; SELECT * FROM people; -- `)
520+
await expect(database.sql(`USE DATABASE ${sanitizedDBName}`)).rejects.toThrow(
521+
`Database name contains invalid characters (${databaseName}; SELECT * FROM people; --).`
522+
)
511523

512-
const table = sanitizeSQLiteIdentifier('people; -- ')
513-
await expect(database.sql(`SELECT * FROM ${table} WHERE people = 1`)).rejects.toThrow('no such table: people; --')
524+
const table = sanitizeSQLiteIdentifier('people; -- ')
525+
await expect(database.sql(`SELECT * FROM ${table} WHERE people = 1`)).rejects.toThrow('no such table: people; --')
526+
} finally {
527+
await removeDatabaseAsync(database)
528+
}
514529
})
515530
})
516531

test/stress.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
EXPECT_SPEED_MS
1515
} from './shared'
1616

17-
describe('stress testing', () => {
17+
describe.skip('stress testing', () => {
1818
it(
1919
'should do lots of read connections in sequence',
2020
async () => {

0 commit comments

Comments
 (0)