@@ -6,13 +6,7 @@ import { SQLiteCloudConnection } from '../src/drivers/connection'
66import { SQLiteCloudWebsocketConnection } from '../src/drivers/connection-ws'
77import { SQLiteCloudCommand } from '../src/drivers/types'
88import { SQLiteCloudError } from '../src/index'
9- import {
10- EXPECT_SPEED_MS ,
11- getChinookConfig ,
12- getChinookWebsocketConnection ,
13- LONG_TIMEOUT ,
14- WARN_SPEED_MS
15- } from './shared'
9+ import { EXPECT_SPEED_MS , getChinookConfig , getChinookWebsocketConnection , LONG_TIMEOUT , WARN_SPEED_MS } from './shared'
1610
1711describe ( 'connection-ws' , ( ) => {
1812 let chinook : SQLiteCloudConnection
@@ -78,6 +72,48 @@ describe('connection-ws', () => {
7872 })
7973 })
8074*/
75+
76+ it (
77+ 'should catch connect_error on connection errors' ,
78+ done => {
79+ const configObj = getChinookConfig ( )
80+ configObj . usewebsocket = true
81+ configObj . host = 'non.existing.host.name'
82+ let connection : SQLiteCloudWebsocketConnection | null = null
83+ connection = new SQLiteCloudWebsocketConnection ( configObj , error => {
84+ try {
85+ expect ( error ) . toBeDefined ( )
86+ expect ( error ?. message ) . toContain ( 'Error: getaddrinfo ENOTFOUND non.existing.host.name' )
87+ connection ?. close ( )
88+ } finally {
89+ done ( )
90+ }
91+ } )
92+ } ,
93+ LONG_TIMEOUT
94+ )
95+
96+ // skip this test since it requires a paused free node
97+ it . skip (
98+ 'should catch connect_error when node is scaled down' ,
99+ done => {
100+ const configObj = getChinookConfig ( "sqlitecloud://paused-node" )
101+ configObj . usewebsocket = true
102+ let connection : SQLiteCloudWebsocketConnection | null = null
103+ connection = new SQLiteCloudWebsocketConnection ( configObj , error => {
104+ try {
105+ expect ( error ) . toBeDefined ( )
106+ const m = error ?. message
107+ expect ( error ?. message . startsWith ( 'Your free node has been paused due to inactivity. To resume usage, please restart your node from your dashboard: https://dashboard.sqlitecloud.io' ) ) . toBe ( true )
108+ connection ?. close ( )
109+ } finally {
110+ done ( )
111+ }
112+ } )
113+ } ,
114+ LONG_TIMEOUT
115+ )
116+
81117 describe ( 'send test commands' , ( ) => {
82118 it ( 'should test integer' , done => {
83119 chinook . sendCommands ( 'TEST INTEGER' , ( error , results ) => {
0 commit comments