Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion __tests__/cls.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ describe('Cls', () => {
topicId: 'e9e38c86-c7ba-475b-a852-6305880d2212',
interval: 3600,
});
console.log('logs', res);
expect(res).toBeInstanceOf(Array);
});
});
2 changes: 1 addition & 1 deletion __tests__/scf.sp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ScfDeployInputs } from '../src/modules/scf/interface';
import { sleep } from '@ygkit/request';
import { Scf } from '../src';

describe('Scf - singapore', () => {
describe('Scf - special', () => {
const credentials = {
SecretId: process.env.TENCENT_SECRET_ID,
SecretKey: process.env.TENCENT_SECRET_KEY,
Expand Down
34 changes: 10 additions & 24 deletions __tests__/scf.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,11 @@ describe('Scf', () => {
expect(outputs.AsyncRunEnable).toBe('FALSE');
expect(outputs.Status).toBe('Active');
expect(outputs.EipConfig).toEqual({ EipFixed: 'TRUE', Eips: expect.any(Array) });
expect(outputs.Layers).toEqual([
{
LayerName: layerInputs.name,
LayerVersion: expect.any(Number),
CompatibleRuntimes: layerInputs.runtimes,
Description: layerInputs.description,
LicenseInfo: '',
AddTime: expect.any(String),
Status: 'Active',
Src: 'Default',
},
]);

expect(outputs.Layers[0].LayerName).toBe(layerInputs.name);
expect(outputs.Layers[0].CompatibleRuntimes).toEqual(layerInputs.runtimes);
expect(outputs.Layers[0].Description).toBe(layerInputs.description);

expect(outputs.PublicNetConfig).toEqual({
PublicNetStatus: 'ENABLE',
EipConfig: { EipStatus: 'ENABLE', EipAddress: expect.any(Array) },
Expand Down Expand Up @@ -348,18 +341,11 @@ describe('Scf', () => {
expect(outputs.AsyncRunEnable).toBe('FALSE');
expect(outputs.Status).toBe('Active');
expect(outputs.EipConfig).toEqual({ EipFixed: 'TRUE', Eips: expect.any(Array) });
expect(outputs.Layers).toEqual([
{
LayerName: layerInputs.name,
LayerVersion: expect.any(Number),
CompatibleRuntimes: layerInputs.runtimes,
Description: layerInputs.description,
LicenseInfo: '',
AddTime: expect.any(String),
Status: 'Active',
Src: 'Default',
},
]);

expect(outputs.Layers[0].LayerName).toBe(layerInputs.name);
expect(outputs.Layers[0].CompatibleRuntimes).toEqual(layerInputs.runtimes);
expect(outputs.Layers[0].Description).toBe(layerInputs.description);

expect(outputs.PublicNetConfig).toEqual({
PublicNetStatus: 'ENABLE',
EipConfig: { EipStatus: 'ENABLE', EipAddress: expect.any(Array) },
Expand Down
3 changes: 0 additions & 3 deletions src/modules/metrics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export default class Metrics {
throw new ApiError({
type: 'API_METRICS_getScfMetrics',
message: e.message,
stack: e.stack,
reqId: e.reqId,
code: e.code,
});
Expand Down Expand Up @@ -105,7 +104,6 @@ export default class Metrics {
throw new ApiError({
type: 'API_METRICS_getApigwMetrics',
message: e.message,
stack: e.stack,
reqId: e.reqId,
code: e.code,
});
Expand Down Expand Up @@ -138,7 +136,6 @@ export default class Metrics {
throw new ApiError({
type: 'API_METRICS_getCustomMetrics',
message: e.message,
stack: e.stack,
reqId: e.reqId,
code: e.code,
});
Expand Down
25 changes: 17 additions & 8 deletions src/modules/scf/entities/scf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,25 @@ export default class ScfEntity extends BaseEntity {
});
return Response;
} catch (e) {
if (e.code == 'ResourceNotFound.FunctionName' || e.code == 'ResourceNotFound.Function') {
if (e.code === 'ResourceNotFound.FunctionName' || e.code === 'ResourceNotFound.Function') {
return null;
}
throw new ApiError({
type: 'API_SCF_GetFunction',
message: e.message,
stack: e.stack,
reqId: e.reqId,
code: e.code,
});
if (e.code === 'InvalidParameterValue.FunctionName') {
throw new ApiError({
type: 'API_SCF_GetFunction',
message: `SCF 函数名称命名不符合规则。 只能包含字母、数字、下划线、连字符,以字母开头,以数字或字母结尾,2~60个字符`,
reqId: e.reqId,
code: e.code,
displayMsg: `SCF 函数名称命名不符合规则。 只能包含字母、数字、下划线、连字符,以字母开头,以数字或字母结尾,2~60个字符`,
});
} else {
throw new ApiError({
type: 'API_SCF_GetFunction',
message: e.message,
reqId: e.reqId,
code: e.code,
});
}
}
}

Expand Down