Skip to content

{} -> nil #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 13, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions qiniu/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ exports.generateAccessToken = function(uri, body) {
exports.getResp = function(onret) {
var onresp = function(res) {
exports.readAll(res, function(data) {
var ret = {};
var err = {};
var err, ret;

if (Math.floor(res.statusCode/100) === 2) {
if (data.length !== 0) {
try {
ret = JSON.parse(data);
} catch (e) {
err = {code: res.statusCode, err: e.toString()};
}
}
} else {
Expand Down
12 changes: 6 additions & 6 deletions test/io.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('test start step1:', function() {

var client = new qiniu.rs.Client();
client.batchDelete(entries, function(err, ret) {
err.should.eql({});
should.not.exist(err);
done();
});
});
Expand All @@ -48,7 +48,7 @@ describe('test start step1:', function() {
it('test upload from memory', function(done) {
var key = 'filename' + Math.random(1000);
qiniu.io.put(uptoken, key, 'content', null, function(err, ret) {
err.should.eql({});
should.not.exist(err);
ret.should.have.keys('hash', 'key');
ret.key.should.equal(key);
keys.push(ret.key);
Expand All @@ -61,7 +61,7 @@ describe('test start step1:', function() {
it('test upload from memory without key', function(done) {
var content = 'content' + Math.random(1000);
qiniu.io.putWithoutKey(uptoken, content, null, function(err, ret) {
err.should.eql({});
should.not.exist(err);
ret.should.have.keys('hash', 'key');
ret.key.should.equal(ret.hash);
keys.push(ret.key);
Expand All @@ -74,7 +74,7 @@ describe('test start step1:', function() {
it('test upload from a file', function(done) {
var key = Math.random() + 'logo.png';
qiniu.io.putFile(uptoken, key, imageFile, null, function(err, ret) {
err.should.eql({});
should.not.exist(err);
ret.should.have.keys('key', 'hash');
ret.key.should.equal(key);
keys.push(ret.key);
Expand All @@ -87,7 +87,7 @@ describe('test start step1:', function() {
extra.checkCrc = 1;
var key = Math.random() + 'logo_crc32.png';
qiniu.io.putFile(uptoken, key, imageFile, extra, function(err, ret) {
err.should.eql({});
should.not.exist(err);
ret.should.have.keys('key', 'hash');
ret.key.should.equal(key);
keys.push(ret.key);
Expand Down Expand Up @@ -115,7 +115,7 @@ describe('test start step1:', function() {
describe('rsf.listPrefix()', function() {
it('list all file in test bucket', function(done) {
qiniu.rsf.listPrefix(TEST_BUCKET, null, null, null, function(err, ret) {
err.should.eql({});
should.not.exist(err);
// ret.data.items.length.should.equal(keys.length);
for (i in ret.items) {
ret.items[i].should.have.keys('key', 'putTime', 'hash', 'fsize', 'mimeType');
Expand Down
24 changes: 12 additions & 12 deletions test/rs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ describe('test start step2:', function() {
var putPolicy = new qiniu.rs.PutPolicy(TEST_BUCKET);
var uptoken = putPolicy.token();
qiniu.io.putFile(uptoken, logo2, imageFile, null, function(err, ret) {
err.should.eql({});
should.not.exist(err);
});
qiniu.io.putFile(uptoken, logo, imageFile, null, function(err, ret) {
err.should.eql({});
should.not.exist(err);
done();
});
});

describe('rs.Client#stat()', function() {
it('get the stat of a file', function(done) {
client.stat(TEST_BUCKET, logo, function(err, ret) {
err.should.eql({});
should.not.exist(err);
ret.should.have.keys('hash', 'fsize', 'putTime', 'mimeType');
done();
});
Expand All @@ -49,7 +49,7 @@ describe('test start step2:', function() {
describe('rs.Client#copy()', function() {
it('copy logo.png to logo1.png', function(done) {
client.copy(TEST_BUCKET, logo, TEST_BUCKET, logo1, function(err, ret) {
err.should.eql({});
should.not.exist(err);
done();
});
});
Expand All @@ -58,7 +58,7 @@ describe('test start step2:', function() {
describe('rs.Client#remove()', function() {
it('remove logo.png', function(done) {
client.remove(TEST_BUCKET, logo, function(err, ret) {
err.should.eql({});
should.not.exist(err);
done();
});
});
Expand All @@ -67,7 +67,7 @@ describe('test start step2:', function() {
describe('rs.Client#move()', function() {
it('move logo1.png to logo.png', function(done) {
client.move(TEST_BUCKET, logo1, TEST_BUCKET, logo, function(err, ret) {
err.should.eql({});
should.not.exist(err);
done();
});
});
Expand All @@ -80,7 +80,7 @@ describe('test start step2:', function() {
var entries = [new EntryPath(TEST_BUCKET, logo), new EntryPath(TEST_BUCKET, logo2)];

client.batchDelete(entries, function(err, ret) {
err.should.eql({});
should.not.exist(err);
done();
});
});
Expand All @@ -92,7 +92,7 @@ describe('test start step2:', function() {
new EntryPath(TEST_BUCKET, logo2)];

client.batchStat(entries, function(err, ret) {
err.should.eql({});
should.not.exist(err);
ret.length.should.equal(2);
for (i in ret) {
ret[i].code.should.equal(200);
Expand All @@ -109,7 +109,7 @@ describe('test start step2:', function() {
new EntryPath(TEST_BUCKET, 'not exist file')];

client.batchStat(entries, function(err, ret) {
err.should.eql({}); // 298
should.not.exist(err); // 298
ret.length.should.equal(2);

for (i in ret) {
Expand All @@ -132,7 +132,7 @@ describe('test start step2:', function() {

it('copy from logo, logo2 to logo1, logo3', function(done) {
client.batchCopy(entries, function(err, ret) {
err.should.eql({});
should.not.exist(err);
console.log(ret);
done();
});
Expand All @@ -144,7 +144,7 @@ describe('test start step2:', function() {

it('delete logo.png, logo2.png', function(done) {
client.batchDelete(entries, function(err, ret) {
err.should.eql({});
should.not.exist(err);
done();
});
});
Expand All @@ -157,7 +157,7 @@ describe('test start step2:', function() {

it('move from logo1.png, logo3.png to logo.png, logo2.png', function(done) {
client.batchMove(entries, function(err, ret) {
err.should.eql({});
should.not.exist(err);
done();
});
});
Expand Down