Skip to content

Commit

Permalink
improved; fixed race condition in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Francisco Treacy committed Nov 18, 2010
1 parent 4705d99 commit 58c2163
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions spec/batch_http.coffee
Expand Up @@ -74,18 +74,17 @@ module.exports =

'document update request':
topic: ->

callback = @callback

db.get bucket, 'test3', (err, data) ->
data.updated = true
data.wtf = 'yes'
data.wee = 42

db.save bucket, 'test3', data, ->
db.get bucket, 'test3', callback
db.save bucket, 'test3', data, { returnbody: true }, callback

'gets updated data': (data) ->
'gets updated data': (err, data, meta) ->
assert.ok data.updated
assert.equal data.wtf, 'yes'
assert.equal data.wee, 42
Expand Down Expand Up @@ -138,7 +137,11 @@ module.exports =

'allow_mult is updated': (response) ->
assert.ok response.props.allow_mult


}

{

'a document':
topic: ->
db.save bucket, 'test1', { name: 'Testing conflicting' }, { returnbody: true }, @callback
Expand All @@ -150,6 +153,7 @@ module.exports =
# we now select the document with name 'Testing conflicting'
# and save (meta passes the correct vclock along)
topic: (data) ->
assert.instanceOf data, Array
[resolved] = data.filter (e) -> e.data.name is 'Testing conflicting'
resolved.meta.returnbody = true
db.save bucket, 'test1', resolved.data, resolved.meta, @callback
Expand Down Expand Up @@ -194,9 +198,9 @@ module.exports =
fs.readFile "#{__dirname}/fixtures/lowcost-pilot.jpg", (err, data) =>
@length = data.length
db.saveLarge 'lowcost-pilot', data, { contentType: 'jpeg' }, (err) ->
setTimeout -> # let's wait for Riak for 50ms
setTimeout -> # let's wait for Riak for 80ms
db.getLarge 'lowcost-pilot', done
, 50
, 80

'returns a Buffer of the same length as the original': (data) ->
assert.instanceOf data, Buffer
Expand Down

0 comments on commit 58c2163

Please sign in to comment.