Comparing version 0.11.0 to 0.11.1
@@ -37,3 +37,3 @@ /** | ||
ctx.RAL_MOCK_ALL = true; | ||
ctx.RAL_MOCK = null; | ||
ctx.RAL_MOCK = {}; | ||
} | ||
@@ -48,3 +48,3 @@ else { | ||
else { | ||
ctx.RAL_MOCK = null; | ||
ctx.RAL_MOCK = {}; | ||
} | ||
@@ -51,0 +51,0 @@ ctx.RAL_MOCK_ALL = false; |
{ | ||
"name": "node-ral", | ||
"version": "0.11.0", | ||
"version": "0.11.1", | ||
"description": "a rpc client for node", | ||
@@ -41,4 +41,4 @@ "main": "index.js", | ||
"devDependencies": { | ||
"request": "2.73.0", | ||
"async": "2.0.0", | ||
"request": "2.74.0", | ||
"async": "2.0.1", | ||
"combined-stream": "1.0.5", | ||
@@ -45,0 +45,0 @@ "formidable": "1.0.17", |
@@ -79,2 +79,3 @@ node-ral | ||
var RAL = require('node-ral').RAL; | ||
var ralP = require('node-ral').RALPromise; // 使用Ral的Promise版接口 | ||
var path = require('path'); | ||
@@ -88,3 +89,3 @@ | ||
module.exports = RAL; | ||
module.exports = ralP; | ||
``` | ||
@@ -97,6 +98,6 @@ | ||
var ral = require('./ral.js'); | ||
var ralP = require('./ral.js'); | ||
var assert = require('assert'); | ||
ral('MAPAPI', { | ||
ralP('MAPAPI', { | ||
data: { | ||
@@ -106,6 +107,6 @@ region: '北京', | ||
} | ||
}).on('data', function (data) { | ||
}).then(function (data) { | ||
assert.equal(data.status, 0); | ||
console.dir(data.results[0]); | ||
}).on('error', function (err) { | ||
}).catch(function (err) { | ||
console.error(err); | ||
@@ -112,0 +113,0 @@ }); |
/** | ||
* @file node-ral | ||
@@ -208,2 +212,29 @@ * @author hefangshi@baidu.com | ||
it.only('should dont mock anything when RAL_MOCK is null', function (done) { | ||
delete process.env.RAL_MOCK; | ||
ral.init({ | ||
confDir: path.join(__dirname, './ral/config'), | ||
mockDir: path.join(__dirname, './ral/mock'), | ||
logger: { | ||
log_path: path.join(__dirname, '../logs'), | ||
app: 'yog-ral' | ||
}, | ||
currentIDC: 'tc' | ||
}); | ||
// should degrade since POST_QS_SERV's enableMock=true | ||
var req = ral('POST_QS_SERV', { | ||
data: { | ||
msg: 'hi', | ||
name: '何方石' | ||
} | ||
}); | ||
req.on('data', function (data) { | ||
done(); | ||
}); | ||
req.on('error', function (err) { | ||
err.message.should.eql('mock fatal hit'); | ||
done(); | ||
}); | ||
}); | ||
}); |
357550
10438
154
30