Permalink
Browse files

Refactor and add integration test for empty bodies in RestXMLClient

  • Loading branch information...
lsegal committed Dec 24, 2012
1 parent f289716 commit ea1e021e028134bbb18982f78e7da0cad27d1c81
Showing with 11 additions and 11 deletions.
  1. +7 −0 features/s3/objects.feature
  2. +2 −7 lib/rest_xml_client.js
  3. +2 −4 test/unit/rest_xml_client.spec.coffee
@@ -24,7 +24,14 @@ Feature: Working with Objects in S3
And the object with the key "hello" should contain "world"
When I write "new world" to the key "hello"
Then the object with the key "hello" should contain "new world"
+
+ # Empty files
+ When I write "" to the key "hello"
+ Then the object with the key "hello" should exist
+ And the object with the key "hello" should contain ""
+
When I delete the object with the key "hello"
Then the object with the key "hello" should not exist
+
# final step here needs to happen to cleanup the shared bucket
And I delete the shared bucket
View
@@ -66,13 +66,8 @@ AWS.RESTXMLClient = inherit(AWS.RESTClient, {
});
}
- if (body) {
- req.body = body;
- req.headers['Content-Length'] = body.length;
- } else {
- req.headers['Content-Length'] = 0;
- }
-
+ req.body = body;
+ req.headers['Content-Length'] = body ? body.length : 0;
},
extractData: function extractData(httpResponse, method) {
@@ -66,10 +66,8 @@ describe 'AWS.RESTXMLClient', ->
expect(req.headers['x-amz-acl']).toEqual('canned-acl')
it 'includes Content-Length header if body is empty', ->
- operation.u = '/{Bucket}'
- operation.i = {m:{Bucket:{l:'uri',r:1},Data:{t:'s',l:'body'}}}
- params = { Bucket: 'bucket-name', Data: '' }
- req = buildRequest(params)
+ operation.i = null
+ req = buildRequest()
expect(req.body).toEqual(null)
expect(req.headers['Content-Length']).toEqual(0)

0 comments on commit ea1e021

Please sign in to comment.