Skip to content

Commit 35bc457

Browse files
committed
change test case
1 parent a5f8a7e commit 35bc457

File tree

6 files changed

+91
-1
lines changed

6 files changed

+91
-1
lines changed

deploy/tencentDeploy.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const fs = require('fs');
4+
const os = require('os');
35
const sinon = require('sinon');
46
const TencentProvider = require('../provider/tencentProvider');
57
const Serverless = require('../test/serverless');
@@ -9,6 +11,8 @@ describe('TencentDeploy', () => {
911
let serverless;
1012
let options;
1113
let tencentDeploy;
14+
let readFileSyncStub;
15+
let homedirStub;
1216

1317
beforeEach(() => {
1418
serverless = new Serverless();
@@ -17,10 +21,24 @@ describe('TencentDeploy', () => {
1721
region: 'ap-guangzhou',
1822
function: 'test'
1923
};
24+
25+
readFileSyncStub = sinon.stub(fs, 'readFileSync')
26+
.returns(`[default]
27+
tencent_secret_key = PYR4a0HSZ******eVvHRe
28+
tencent_secret_id = AKIDoM*****mxsfOirI
29+
tencent_appid = 12561*****`);
30+
homedirStub = sinon.stub(os, 'homedir')
31+
.returns('/root');
32+
2033
serverless.setProvider('tencent', new TencentProvider(serverless, options));
2134
tencentDeploy = new TencentDeploy(serverless, options);
2235
});
2336

37+
afterEach(() => {
38+
fs.readFileSync.restore();
39+
os.homedir.restore();
40+
});
41+
2442
describe('#constructor()', () => {
2543
it('should set the serverless instance', () => {
2644
tencentDeploy.serverless.should.equal(serverless);

deploy/tencentDeployFunction.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const fs = require('fs');
4+
const os = require('os');
35
const sinon = require('sinon');
46
const TencentProvider = require('../provider/tencentProvider');
57
const Serverless = require('../test/serverless');
@@ -9,6 +11,8 @@ describe('TencentDeployFunction', () => {
911
let serverless;
1012
let options;
1113
let tencentDeployFunction;
14+
let readFileSyncStub;
15+
let homedirStub;
1216

1317
beforeEach(() => {
1418
serverless = new Serverless();
@@ -17,10 +21,24 @@ describe('TencentDeployFunction', () => {
1721
region: 'ap-guangzhou',
1822
function: 'test'
1923
};
24+
25+
readFileSyncStub = sinon.stub(fs, 'readFileSync')
26+
.returns(`[default]
27+
tencent_secret_key = PYR4a0HSZ******eVvHRe
28+
tencent_secret_id = AKIDoM*****mxsfOirI
29+
tencent_appid = 12561*****`);
30+
homedirStub = sinon.stub(os, 'homedir')
31+
.returns('/root');
32+
2033
serverless.setProvider('tencent', new TencentProvider(serverless, options));
2134
tencentDeployFunction = new TencentDeployFunction(serverless, options);
2235
});
2336

37+
afterEach(() => {
38+
fs.readFileSync.restore();
39+
os.homedir.restore();
40+
});
41+
2442
describe('#constructor()', () => {
2543
it('should set the serverless instance', () => {
2644
tencentDeployFunction.serverless.should.equal(serverless);

deploy/tencentDeployList.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const fs = require('fs');
4+
const os = require('os');
35
const sinon = require('sinon');
46
const TencentProvider = require('../provider/tencentProvider');
57
const Serverless = require('../test/serverless');
@@ -9,6 +11,8 @@ describe('TencentDeployList', () => {
911
let serverless;
1012
let options;
1113
let tencentDeployList;
14+
let readFileSyncStub;
15+
let homedirStub;
1216

1317
beforeEach(() => {
1418
serverless = new Serverless();
@@ -17,10 +21,24 @@ describe('TencentDeployList', () => {
1721
region: 'ap-guangzhou',
1822
function: 'test'
1923
};
24+
25+
readFileSyncStub = sinon.stub(fs, 'readFileSync')
26+
.returns(`[default]
27+
tencent_secret_key = PYR4a0HSZ******eVvHRe
28+
tencent_secret_id = AKIDoM*****mxsfOirI
29+
tencent_appid = 12561*****`);
30+
homedirStub = sinon.stub(os, 'homedir')
31+
.returns('/root');
32+
2033
serverless.setProvider('tencent', new TencentProvider(serverless, options));
2134
tencentDeployList = new TencentDeployList(serverless, options);
2235
});
2336

37+
afterEach(() => {
38+
fs.readFileSync.restore();
39+
os.homedir.restore();
40+
});
41+
2442
describe('#constructor()', () => {
2543
it('should set the serverless instance', () => {
2644
tencentDeployList.serverless.should.equal(serverless);

deploy/tencentDeployListFunctions.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const fs = require('fs');
4+
const os = require('os');
35
const sinon = require('sinon');
46
const TencentProvider = require('../provider/tencentProvider');
57
const Serverless = require('../test/serverless');
@@ -9,6 +11,8 @@ describe('TencentDeployListFunctions', () => {
911
let serverless;
1012
let options;
1113
let tencentDeployListFunctions;
14+
let readFileSyncStub;
15+
let homedirStub;
1216

1317
beforeEach(() => {
1418
serverless = new Serverless();
@@ -17,10 +21,24 @@ describe('TencentDeployListFunctions', () => {
1721
region: 'ap-guangzhou',
1822
function: 'test'
1923
};
24+
25+
readFileSyncStub = sinon.stub(fs, 'readFileSync')
26+
.returns(`[default]
27+
tencent_secret_key = PYR4a0HSZ******eVvHRe
28+
tencent_secret_id = AKIDoM*****mxsfOirI
29+
tencent_appid = 12561*****`);
30+
homedirStub = sinon.stub(os, 'homedir')
31+
.returns('/root');
32+
2033
serverless.setProvider('tencent', new TencentProvider(serverless, options));
2134
tencentDeployListFunctions = new TencentDeployListFunctions(serverless, options);
2235
});
2336

37+
afterEach(() => {
38+
fs.readFileSync.restore();
39+
os.homedir.restore();
40+
});
41+
2442
describe('#constructor()', () => {
2543
it('should set the serverless instance', () => {
2644
tencentDeployListFunctions.serverless.should.equal(serverless);

provider/tencentProvider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class TencentProvider {
2121
this.getCredentials(this.serverless, this.options);
2222
this.serverless.setProvider(constants.providerName, this);
2323
this.provider = this;
24-
this.getServiceResource();
24+
// this.getServiceResource();
2525
}
2626

2727
jsonObjectIsEmpty(jsonObject) {

rollback/tencentRollback.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const fs = require('fs');
4+
const os = require('os');
35
const sinon = require('sinon');
46
const TencentProvider = require('../provider/tencentProvider');
57
const Serverless = require('../test/serverless');
@@ -9,6 +11,8 @@ describe('TencentRollback', () => {
911
let serverless;
1012
let options;
1113
let tencentRollback;
14+
let readFileSyncStub;
15+
let homedirStub;
1216

1317
beforeEach(() => {
1418
serverless = new Serverless();
@@ -17,10 +21,24 @@ describe('TencentRollback', () => {
1721
region: 'ap-guangzhou',
1822
function: 'test'
1923
};
24+
25+
readFileSyncStub = sinon.stub(fs, 'readFileSync')
26+
.returns(`[default]
27+
tencent_secret_key = PYR4a0HSZ******eVvHRe
28+
tencent_secret_id = AKIDoM*****mxsfOirI
29+
tencent_appid = 12561*****`);
30+
homedirStub = sinon.stub(os, 'homedir')
31+
.returns('/root');
32+
2033
serverless.setProvider('tencent', new TencentProvider(serverless, options));
2134
tencentRollback = new TencentRollback(serverless, options);
2235
});
2336

37+
afterEach(() => {
38+
fs.readFileSync.restore();
39+
os.homedir.restore();
40+
});
41+
2442
describe('#constructor()', () => {
2543
it('should set the serverless instance', () => {
2644
tencentRollback.serverless.should.equal(serverless);

0 commit comments

Comments
 (0)