提交 f7df2c45 编写于 作者: Q Quinton.Xu

add test

上级 96b082ab
......@@ -5,7 +5,7 @@
## Install
```bash
$ npm i node-apollo --save-dev --registry=http://http://116.62.161.40:7002
$ npm i node-apollo --save-dev
```
## Usage
......
'use strict';
const urllib = require('urllib');
const assert = require('assert');
const helper = require('./helper');
module.exports = {
remoteConfigService: async (token, config) => {
remoteConfigService: async (config) => {
assert(config, 'param config is required');
assert(config.token, 'param token is required');
const options = {
method: 'GET',
headers: {
'Content-Type': 'application/json;charset=UTF-8',
authorization: token,
authorization: config.token,
},
rejectUnauthorized: false,
contentType: 'json',
dataType: 'json',
};
const res = await urllib.request(helper.getAllConfigFromApolloUri(config), options);
console.log(res.data)
return helper.mergeConfig(res.data);
// ctx.app.config = 2
},
};
\ No newline at end of file
{
"name": "node-apollo",
"version": "1.0.0",
"version": "1.0.3",
"description": "携程Apollo配置中心SDK。",
"main": "index.js",
"scripts": {
......@@ -21,6 +21,7 @@
"mocha": "^3.5.3"
},
"dependencies": {
"test": "^1.0.0",
"urllib": "^2.25.0"
}
}
......@@ -6,14 +6,14 @@ const apollo = require('../index.js');
describe('#index', function () {
it('index.remoteConfigService', async () => {
const config = {
configServerUrl: 'http://116.62.161.40:8070',
appId: 'gnetlink-cms-api',
configServerUrl: 'http://example.com',
appId: '<appId>',
clusterName: 'default',
namespaceName: '',
apolloEnv: 'dev',
// clientIp: '',
};
const token = '9037a4e8c14c3d61ac5dbbdfa379fc56f0e098ff';
const token = '<apollo access token>';
const result = await apollo.remoteConfigService(token, config);
assert(Object.keys(result).length > 0, 'Read config failed');
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册