Permalink
Browse files

Fixed integration tests. Database connections close cleanly now.

  • Loading branch information...
1 parent 9e1f400 commit ead4db070a80df188d1e91da4fbd2c7fc8646bee @josephg committed Jan 23, 2012
Showing with 11 additions and 4 deletions.
  1. +1 −0 src/server/index.coffee
  2. +5 −0 src/server/model.coffee
  3. +3 −3 test/integration.coffee
  4. +1 −1 webclient/share.js
  5. +1 −0 webclient/share.uncompressed.js
@@ -34,6 +34,7 @@ create.attach = attach = (server, options, model = createModel(options)) ->
options.staticpath ?= '/share'
server.model = model
+ server.on 'close', -> model.closeDb()
server.use options.staticpath, connect.static("#{__dirname}/../../webclient") if options.staticpath != null
@@ -571,6 +571,11 @@ module.exports = Model = (db, options) ->
# If nothing was queued, terminate immediately.
callback?() if pendingWrites is 0
+ # Close the database connection. This is needed so nodejs can shut down cleanly.
+ @closeDb = ->
+ db?.close?()
+ db = null
+
return
# Model inherits from EventEmitter.
@@ -51,9 +51,9 @@ genTests = (client, dbType) -> testCase
# We use 127.0.0.1 here so if the process runs out of file handles,
# we'll get the correct error message instead of a generic DNS connection
# error.
- @c1 = new client.Connection "http://127.0.0.1:#{@port}/sjs"
+ @c1 = new client.Connection "http://127.0.0.1:#{@port}/channel"
@c1.on 'connect', =>
- @c2 = new client.Connection "http://127.0.0.1:#{@port}/sjs"
+ @c2 = new client.Connection "http://127.0.0.1:#{@port}/channel"
@c2.on 'connect', =>
callback()
@@ -95,7 +95,7 @@ genTests = (client, dbType) -> testCase
num = 0
nextDocName = -> "doc#{num++}"
- host = "http://127.0.0.1:#{@port}/sjs"
+ host = "http://127.0.0.1:#{@port}/channel"
more = ->
client.open nextDocName(), 'text', host, (error, doc) =>
View
Oops, something went wrong.
Oops, something went wrong.

0 comments on commit ead4db0

Please sign in to comment.