Skip to content

Commit f090c79

Browse files
committed
fix(scf): support update to disable traceEnable
1 parent 827cd67 commit f090c79

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

__tests__/scf.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ describe('Scf', () => {
8989
const events = Object.entries(triggers).map(([, value]) => value);
9090

9191
const inputs: ScfDeployInputs = {
92-
// name: `serverless-test-${Date.now()}`,
93-
name: `serverless-test-fixed`,
92+
name: `serverless-test-${Date.now()}`,
9493
code: {
9594
bucket: process.env.BUCKET,
9695
object: 'express_code.zip',
@@ -573,6 +572,15 @@ describe('Scf', () => {
573572
expect(outputs.AsyncRunEnable).toBe('TRUE');
574573
expect(outputs.TraceEnable).toBe('TRUE');
575574
});
575+
test('[asyncRunEnable and traceEnable] update', async () => {
576+
await sleep(3000);
577+
inputs.asyncRunEnable = true;
578+
inputs.traceEnable = false;
579+
outputs = await scf.deploy(inputs);
580+
581+
expect(outputs.AsyncRunEnable).toBe('TRUE');
582+
expect(outputs.TraceEnable).toBe('FALSE');
583+
});
576584
test('[asyncRunEnable and traceEnable] remove', async () => {
577585
const res = await scf.remove({
578586
functionName: inputs.name,

src/modules/scf/entities/scf.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ export default class ScfEntity extends BaseEntity {
167167
delete reqInputs.Code;
168168
delete reqInputs.CodeSource;
169169
delete reqInputs.AsyncRunEnable;
170-
delete reqInputs.TraceEnable;
171170

172171
// +++++++++++++++++++++++
173172
// FIXME: 以下是函数绑定层逻辑,当函数有一个层,更新的时候想删除,需要传递参数 Layers 不能为空,必须包含特殊元素:{ LayerName: '', LayerVersion: 0 }

src/modules/scf/utils.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,9 @@ export const formatInputs = (region: RegionType, inputs: ScfCreateFunctionInputs
144144
if (inputs.asyncRunEnable !== undefined) {
145145
functionInputs.AsyncRunEnable = inputs.asyncRunEnable === true ? 'TRUE' : 'FALSE';
146146
}
147-
// 只有配置 asyncRunEnable 为 true 时,才能配置 traceEnable 为 true
148-
if (inputs.traceEnable === true && functionInputs.AsyncRunEnable === 'TRUE') {
149-
functionInputs.TraceEnable = 'TRUE';
150-
} else {
151-
functionInputs.TraceEnable = 'FALSE';
147+
148+
if (inputs.traceEnable !== undefined) {
149+
functionInputs.TraceEnable = inputs.traceEnable === true ? 'TRUE' : 'FALSE';
152150
}
153151

154152
return functionInputs;

0 commit comments

Comments
 (0)