Skip to content

Commit b6e59e5

Browse files
committed
split unittest/integration test cases
1 parent fc02446 commit b6e59e5

File tree

7 files changed

+96
-81
lines changed

7 files changed

+96
-81
lines changed

.travis.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@ node_js:
44
- "10"
55
- "8"
66

7+
branches:
8+
only:
9+
- master
10+
711
script:
812
- npm run ci
13+
- test -z $ACCESS_KEY_ID -a -z $ACCESS_KEY_SECRET || npm run test-integration

lib/rpc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class RPCClient {
179179
if (opts.method === 'POST') {
180180
opts.headers = {};
181181
opts.headers['content-type'] = 'application/x-www-form-urlencoded';
182-
opts.data = canonicalize(normalized)
182+
opts.data = canonicalize(normalized);
183183
}
184184

185185
return httpx.request(url, opts).then((response) => {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"lint": "eslint --fix lib test",
99
"test": "mocha -R spec test/*.test.js",
1010
"test-cov": "nyc -r=html -r=text -r=lcov mocha -t 3000 -R spec test/*.test.js",
11+
"test-integration": "mocha -R spec test/*.integration.js",
1112
"ci": "npm run lint && npm run test-cov && codecov"
1213
},
1314
"keywords": [

test/roa.integration.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use strict';
2+
3+
const expect = require('expect.js');
4+
5+
const ROAClient = require('../lib/roa');
6+
7+
describe('request', function () {
8+
var client = new ROAClient({
9+
accessKeyId: process.env.ACCESS_KEY_ID,
10+
accessKeySecret: process.env.ACCESS_KEY_SECRET,
11+
endpoint: 'http://ros.aliyuncs.com',
12+
apiVersion: '2015-09-01'
13+
});
14+
15+
it('request', async function () {
16+
this.timeout(15000);
17+
var result = await client.request('GET', '/regions', {}, '', {}, {
18+
timeout: 15000
19+
});
20+
expect(result).to.have.property('Regions');
21+
});
22+
23+
it('get should ok', async function () {
24+
this.timeout(10000);
25+
var result = await client.get('/regions', {}, {}, {
26+
timeout: 10000
27+
});
28+
expect(result).to.have.property('Regions');
29+
});
30+
31+
it('get raw body should ok', async function () {
32+
this.timeout(10000);
33+
var opts = {
34+
rawBody: true,
35+
timeout: 10000
36+
};
37+
var result = await client.get('/regions', {}, {}, opts);
38+
expect(result).to.be.a('string');
39+
});
40+
});

test/roa.test.js

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -106,39 +106,4 @@ describe('roa core', function() {
106106
});
107107
});
108108
});
109-
110-
describe('request', function () {
111-
var client = new ROAClient({
112-
accessKeyId: process.env.ACCESS_KEY_ID,
113-
accessKeySecret: process.env.ACCESS_KEY_SECRET,
114-
endpoint: 'http://ros.aliyuncs.com',
115-
apiVersion: '2015-09-01'
116-
});
117-
118-
it('request', async function () {
119-
this.timeout(10000);
120-
var result = await client.request('GET', '/regions', {}, '', {}, {
121-
timeout: 10000
122-
});
123-
expect(result).to.have.property('Regions');
124-
});
125-
126-
it('get should ok', async function () {
127-
this.timeout(10000);
128-
var result = await client.get('/regions', {}, {}, {
129-
timeout: 10000
130-
});
131-
expect(result).to.have.property('Regions');
132-
});
133-
134-
it('get raw body should ok', async function () {
135-
this.timeout(10000);
136-
var opts = {
137-
rawBody: true,
138-
timeout: 10000
139-
};
140-
var result = await client.get('/regions', {}, {}, opts);
141-
expect(result).to.be.a('string');
142-
});
143-
});
144109
});

test/rpc.integration.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
'use strict';
2+
3+
const expect = require('expect.js');
4+
5+
const RPCClient = require('../lib/rpc');
6+
7+
describe('request', function() {
8+
var client = new RPCClient({
9+
accessKeyId: process.env.ACCESS_KEY_ID,
10+
accessKeySecret: process.env.ACCESS_KEY_SECRET,
11+
endpoint: 'https://ecs.aliyuncs.com',
12+
apiVersion: '2014-05-26'
13+
});
14+
15+
it('should ok', async function() {
16+
this.timeout(15000);
17+
18+
var params = {
19+
key: ['1', '2', '3', '4', '5', '6', '7', '8', '9',
20+
'10', '11']
21+
};
22+
23+
var requestOption = {
24+
method: 'POST',
25+
timeout: 15000
26+
};
27+
28+
const result = await client.request('DescribeRegions', params, requestOption);
29+
expect(result).to.have.key('RequestId');
30+
expect(result).to.have.key('Regions');
31+
});
32+
33+
it('should ok with repeat list less 10 item', async function() {
34+
this.timeout(15000);
35+
36+
var params = {
37+
key: ['1', '2', '3', '4', '5', '6', '7', '8', '9']
38+
};
39+
40+
var requestOption = {
41+
method: 'POST',
42+
timeout: 15000
43+
};
44+
45+
const result = await client.request('DescribeRegions', params, requestOption);
46+
expect(result).to.have.key('RequestId');
47+
expect(result).to.have.key('Regions');
48+
});
49+
});

test/rpc.test.js

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -172,50 +172,5 @@ describe('rpc core', function() {
172172
['c', 'value']
173173
])).to.be('a=value&b=value&c=value');
174174
});
175-
176-
});
177-
178-
describe('request', function() {
179-
var client = new RPCClient({
180-
accessKeyId: process.env.ACCESS_KEY_ID,
181-
accessKeySecret: process.env.ACCESS_KEY_SECRET,
182-
endpoint: 'https://ecs.aliyuncs.com',
183-
apiVersion: '2014-05-26'
184-
});
185-
186-
it('should ok', async function() {
187-
this.timeout(10000);
188-
189-
var params = {
190-
key: ['1', '2', '3', '4', '5', '6', '7', '8', '9',
191-
'10', '11']
192-
};
193-
194-
var requestOption = {
195-
method: 'POST',
196-
timeout: 10000
197-
};
198-
199-
const result = await client.request('DescribeRegions', params, requestOption);
200-
expect(result).to.have.key('RequestId');
201-
expect(result).to.have.key('Regions');
202-
});
203-
204-
it('should ok with repeat list less 10 item', async function() {
205-
this.timeout(10000);
206-
207-
var params = {
208-
key: ['1', '2', '3', '4', '5', '6', '7', '8', '9']
209-
};
210-
211-
var requestOption = {
212-
method: 'POST',
213-
timeout: 10000
214-
};
215-
216-
const result = await client.request('DescribeRegions', params, requestOption);
217-
expect(result).to.have.key('RequestId');
218-
expect(result).to.have.key('Regions');
219-
});
220175
});
221176
});

0 commit comments

Comments
 (0)