Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

addFile() should return the response from the server

  • Loading branch information...
commit 86326c5d9361026cc680d0944ff80327fcc2af73 1 parent c6ae24c
@fearphage authored
Showing with 23 additions and 8 deletions.
  1. +23 −8 test/storage-object-test.js
View
31 test/storage-object-test.js
@@ -13,7 +13,7 @@ var path = require('path'),
cloudfiles = require('../lib/cloudfiles'),
helpers = require('./helpers');
-var testData = {}, client = helpers.createClient(),
+var testData = {}, client = helpers.createClient(),
sampleData = fs.readFileSync(path.join(__dirname, '..', 'test', 'fixtures', 'fillerama.txt')).toString();
vows.describe('node-cloudfiles/storage-object').addBatch(helpers.requireAuth(client)).addBatch({
@@ -24,7 +24,7 @@ vows.describe('node-cloudfiles/storage-object').addBatch(helpers.requireAuth(cli
remote: 'file1.txt',
local: path.join(__dirname, '..', 'test', 'fixtures', 'fillerama.txt')
}, function () { });
-
+
ustream.on('end', this.callback);
},
"should raise the `end` event": function () {
@@ -40,7 +40,7 @@ vows.describe('node-cloudfiles/storage-object').addBatch(helpers.requireAuth(cli
remote: 'file2.txt',
local: path.join(__dirname, '..', 'test', 'fixtures', 'fillerama.txt')
}, function () { });
-
+
ustream.on('end', this.callback)
},
"should raise the `end` event": function () {
@@ -56,13 +56,13 @@ vows.describe('node-cloudfiles/storage-object').addBatch(helpers.requireAuth(cli
readStream = fs.createReadStream(fileName),
headers = { 'content-length': fs.statSync(fileName).size },
ustream;
-
+
ustream = client.addFile('test_container', {
remote: 'file3.txt',
stream: readStream,
headers: headers
}, this.callback);
-
+
ustream.on('end', this.callback);
},
"should raise the `end` event": function () {
@@ -74,12 +74,12 @@ vows.describe('node-cloudfiles/storage-object').addBatch(helpers.requireAuth(cli
var fileName = path.join(__dirname, '..', 'test', 'fixtures', 'fillerama.txt'),
readStream = fs.createReadStream(fileName),
ustream;
-
+
ustream = client.addFile('test_container', {
remote: 'file3.txt',
stream: readStream
}, this.callback);
-
+
ustream.on('end', this.callback);
},
"should raise the `end` event": function () {
@@ -89,6 +89,21 @@ vows.describe('node-cloudfiles/storage-object').addBatch(helpers.requireAuth(cli
}
}).addBatch({
"The node-cloudfiles client": {
+ "the addFile() method": {
+ topic: function () {
+ client.addFile('test_container', {
+ remote: 'file3.txt',
+ local: path.join(__dirname, '..', 'test', 'fixtures', 'fillerama.txt')
+ }, this.callback);
+ },
+ "returns the response": function(err, response) {
+ assert.equal(typeof response, 'object');
+ assert.isTrue('headers' in response);
+ }
+ }
+ }
+}).addBatch({
+ "The node-cloudfiles client": {
"the getFiles() method": {
topic: function () {
client.getFiles('test_container', this.callback);
@@ -124,7 +139,7 @@ vows.describe('node-cloudfiles/storage-object').addBatch(helpers.requireAuth(cli
if (err) {
return self.callback(err);
}
-
+
fs.stat(filename, self.callback)
});
},
Please sign in to comment.
Something went wrong with that request. Please try again.