Permalink
Browse files

Add request timeout test

  • Loading branch information...
1 parent 879eb24 commit 25e56b84cb6ee587b8e1b1de3277af3f69a31981 @patriksimek patriksimek committed Jun 15, 2014
Showing with 53 additions and 0 deletions.
  1. +53 −0 test/integration/connection-test.coffee
@@ -851,4 +851,57 @@ exports.cancelRequest = (test) ->
connection.on('debug', (text) ->
#console.log(text)
+ )
+
+exports.requestTimeout = (test) ->
+ test.expect(8)
+
+ config = getConfig()
+ config.options.requestTimeout = 1000
+
+ request = new Request('select 1 as C1;waitfor delay \'00:00:05\';select 2 as C2', (err, rowCount, rows) ->
+ test.equal err.message, 'Timeout: Request failed to complete in 1000ms'
+
+ connection.close()
+ )
+
+ request.on('doneInProc', (rowCount, more) ->
+ test.ok false
+ )
+
+ request.on('doneProc', (rowCount, more) ->
+ test.ok !rowCount
+ test.strictEqual more, false
+ )
+
+ request.on('done', (rowCount, more, rows) ->
+ test.ok !rowCount
+ test.strictEqual more, false
+ )
+
+ request.on('columnMetadata', (columnsMetadata) ->
+ test.strictEqual(columnsMetadata.length, 1)
+ )
+
+ request.on('row', (columns) ->
+ test.strictEqual(columns.length, 1)
+ test.strictEqual(columns[0].value, 1)
+ )
+
+ connection = new Connection(config)
+
+ connection.on('connect', (err) ->
+ connection.execSql(request)
+ )
+
+ connection.on('end', (info) ->
+ test.done()
+ )
+
+ connection.on('infoMessage', (info) ->
+ #console.log("#{info.number} : #{info.message}")
+ )
+
+ connection.on('debug', (text) ->
+ #console.log(text)
)

0 comments on commit 25e56b8

Please sign in to comment.