File tree 3 files changed +39
-4
lines changed
3 files changed +39
-4
lines changed Original file line number Diff line number Diff line change @@ -53,9 +53,7 @@ exports.waitDatabaseReady = function(callback) {
53
53
tryConnect ( ) ;
54
54
} ;
55
55
56
- exports . createConnection = function ( args ) {
57
-
58
- const driver = require ( '../index.js' ) ;
56
+ function createConnectionFromDriver ( driver , args ) {
59
57
if ( ! args ?. port && process . env . MYSQL_CONNECTION_URL ) {
60
58
return driver . createConnection ( { ...args , uri : process . env . MYSQL_CONNECTION_URL } )
61
59
}
@@ -88,6 +86,18 @@ exports.createConnection = function(args) {
88
86
89
87
const conn = driver . createConnection ( params ) ;
90
88
return conn ;
89
+ }
90
+
91
+ exports . createConnection = function ( args ) {
92
+
93
+ const driver = require ( '../index.js' ) ;
94
+ return createConnectionFromDriver ( driver , args ) ;
95
+ } ;
96
+
97
+ exports . createConnectionPromise = function ( args ) {
98
+
99
+ const driver = require ( '../promise.js' ) ;
100
+ return createConnectionFromDriver ( driver , args ) ;
91
101
} ;
92
102
93
103
exports . getConfig = function ( input ) {
Original file line number Diff line number Diff line change
1
+ import * as common from '../../common.js' ;
2
+ import assert from 'node:assert' ;
3
+
4
+ function killConnection ( connectionId ) {
5
+ const killer = common . createConnection ( ) ;
6
+ killer . query ( 'KILL ?' , [ connectionId ] ) ;
7
+ killer . end ( ) ;
8
+ }
9
+
10
+ const connection = await common . createConnectionPromise ( ) ;
11
+ const query = connection . connection . query ( 'SELECT SLEEP(10)' ) ;
12
+ const stream = query . stream ( ) ;
13
+
14
+ // kill the connection
15
+ killConnection ( connection . threadId ) ;
16
+
17
+ try {
18
+ // iterate the streaming result here
19
+ for await ( const row of stream ) {
20
+ // do stuff with row
21
+ }
22
+ assert . fail ( 'The query stream should have thrown the connection error' ) ;
23
+ } catch ( e ) {
24
+ assert . ok ( 'The query stream has thrown the connection error' ) ;
25
+ }
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ const options = {
7
7
} ;
8
8
9
9
if ( process . env . FILTER ) {
10
- options . include = new RegExp ( `${ process . env . FILTER } .*\\.js$` ) ;
10
+ options . include = new RegExp ( `${ process . env . FILTER } .*\\.m? js$` ) ;
11
11
}
12
12
13
13
require ( 'urun' ) ( __dirname , options ) ;
You can’t perform that action at this time.
0 commit comments