Skip to content

Commit

Permalink
Clean up test
Browse files Browse the repository at this point in the history
  • Loading branch information
AdityaManohar committed Dec 5, 2014
1 parent 9d7c413 commit 68b60c4
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions test/services/dynamodb.spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,31 @@ describe 'AWS.DynamoDB', ->
dynamo = ddb(accessKeyId: 'AKID', secretAccessKey: 'SECRET', region: 'us-west-2')

if AWS.util.isNode()
it 'does not verify response checksum when streaming', ->
it 'does not verify response checksum when streaming', (done) ->
err = null
helpers.mockHttpResponse 200, {'x-amz-crc32': '0'}, """{"TableNames":["mock-table"]}"""
request = dynamo.makeRequest('listTables')
request = dynamo.listTables()
request.on 'complete', ->
expect(err).to.eql(null)
done()
s = request.createReadStream()
s.on 'end', ->
expect(request.error).to.eql(null)
s.on 'data', ->
s.on 'error', (e) -> err = e

it 'does verify response checksum when not streaming', ->
helpers.mockHttpResponse 200, {'x-amz-crc32': '1575962599'}, """{"TableNames":["mock-table"]}"""
request = dynamo.makeRequest('listTables')
request = dynamo.listTables()
request.send (err, data) ->
expect(err).to.eql(null)

it 'does not verify response checksum when no [x-amz-crc32] header', ->
helpers.mockHttpResponse 200, {}, """{"TableNames":["mock-table"]}"""
request = dynamo.makeRequest('listTables')
request = dynamo.listTables()
request.send (err, data) ->
expect(err).to.eql(null)

it 'throws an error when response checksum does not match', ->
helpers.mockHttpResponse 200, {'x-amz-crc32': '0'}, """{"TableNames":["mock-table"]}"""
request = dynamo.makeRequest('listTables')
request = dynamo.listTables()
request.send (err, data) ->
expect(err.code).to.eql('CRC32CheckFailed')

0 comments on commit 68b60c4

Please sign in to comment.