Skip to content

Commit 49af2f5

Browse files
committed
chore: add cfs test for scf
1 parent ce40fdf commit 49af2f5

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

src/modules/cfs/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { Capi } = require('@tencent-sdk/capi');
22
const apis = require('./apis');
33

4-
class Layer {
4+
class CFS {
55
constructor(credentials = {}, region) {
66
this.region = region || 'ap-guangzhou';
77
this.credentials = credentials;
@@ -96,4 +96,4 @@ class Layer {
9696
}
9797
}
9898

99-
module.exports = Layer;
99+
module.exports = CFS;

src/modules/scf/index.test.js

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
const ScfUtils = require('./index');
2+
const CFS = require('../cfs');
23

34
class ClientTest {
45
async scfTest() {
5-
const scf = new ScfUtils({
6+
const credentials = {
67
SecretId: '',
78
SecretKey: '',
8-
});
9+
};
10+
const scf = new ScfUtils(credentials);
911
const inputs = {
1012
name: 'express-test',
1113
code: {
1214
bucket: 'sls-cloudfunction-ap-guangzhou-code',
13-
object: 'express_component_5dwuabh-1597994417.zip',
15+
object: 'express_component_5dwuabh-1598513206.zip',
1416
},
1517
role: 'SCF_QcsRole',
1618
handler: 'sl_handler.handler',
@@ -29,6 +31,16 @@ class ClientTest {
2931
},
3032
},
3133
eip: true,
34+
vpcConfig: {
35+
vpcId: 'vpc-cp54x9m7',
36+
subnetId: 'subnet-267yufru',
37+
},
38+
cfs: [
39+
{
40+
localMountDir: '/mnt/',
41+
remoteMountDir: '/',
42+
},
43+
],
3244
events: [
3345
{
3446
timer: {
@@ -69,6 +81,24 @@ class ClientTest {
6981
],
7082
};
7183

84+
// 0. deploy cfs
85+
const cfsInputs = {
86+
fsName: 'cfs-test',
87+
region: 'ap-guangzhou',
88+
zone: 'ap-guangzhou-3',
89+
netInterface: 'VPC',
90+
vpc: {
91+
vpcId: 'vpc-cp54x9m7',
92+
subnetId: 'subnet-267yufru',
93+
},
94+
};
95+
const cfsClient = new CFS(credentials, inputs.region);
96+
const cfsRes = await cfsClient.deploy(cfsInputs);
97+
console.log('cfs deploy: ', JSON.stringify(cfsRes));
98+
console.log('++++++++++++++++++');
99+
inputs.cfs[0].cfsId = cfsRes.fileSystemId;
100+
101+
72102
// 1. deploy test
73103
const res1 = await scf.deploy(inputs);
74104
console.log('deploy: ', JSON.stringify(res1));
@@ -106,6 +136,9 @@ class ClientTest {
106136
await scf.remove({
107137
functionName: inputs.name,
108138
});
139+
140+
// 5. remove cfs
141+
await cfsClient.remove(cfsRes);
109142
}
110143
}
111144

0 commit comments

Comments
 (0)