Enhance the test case

This commit is contained in:
Raymond Feng 2013-06-24 16:05:25 -07:00
parent e53f369cfc
commit 8eab9b5614
1 changed files with 10 additions and 7 deletions

View File

@ -86,17 +86,20 @@ describe('FileSystem based storage provider', function () {
}); });
it('should upload a file', function (done) { it('should upload a file', function (done) {
fs.createReadStream(path.join(__dirname, 'files/f1.txt')).pipe( var writer = client.upload({container: 'c1', remote: 'f1.txt'});
client.upload({container: 'c1', remote: 'f1.txt'})); fs.createReadStream(path.join(__dirname, 'files/f1.txt')).pipe(writer);
done(); writer.on('finish', done);
writer.on('error', done);
}); });
it('should download a file', function (done) { it('should download a file', function (done) {
client.download({ var reader = client.download({
container: 'c1', container: 'c1',
remote: 'f1.txt' remote: 'f1.txt'
}).pipe(fs.createWriteStream(path.join(__dirname, 'files/f1_downloaded.txt'))); });
done(); reader.pipe(fs.createWriteStream(path.join(__dirname, 'files/f1_downloaded.txt')));
reader.on('end', done);
reader.on('error', done);
}); });
it('should get files for a container', function (done) { it('should get files for a container', function (done) {
@ -117,7 +120,7 @@ describe('FileSystem based storage provider', function () {
it('should destroy a container c1', function (done) { it('should destroy a container c1', function (done) {
client.destroyContainer('c1', function (err, container) { client.destroyContainer('c1', function (err, container) {
console.error(err); // console.error(err);
assert(!err); assert(!err);
done(err, container); done(err, container);
}); });