Skip to content

Commit 1111417

Browse files
committed
test/changelog
1 parent d5e9930 commit 1111417

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

packages/core/src/lambda/remoteDebugging/ldkClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ export class LdkClient {
401401
}
402402

403403
async deleteDebugVersion(functionArn: string, qualifier: string) {
404-
if (!qualifier || qualifier === '$LATEST'){
404+
if (!qualifier || qualifier === '$LATEST') {
405405
// avoid deleting function directly
406406
return true
407407
}

packages/core/src/test/lambda/remoteDebugging/ldkClient.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,24 @@ describe('LdkClient', () => {
348348
assert(mockLambdaClient.deleteFunction.calledOnce, 'Should call deleteFunction')
349349
})
350350

351+
it('should skip deletion when qualifier is empty or latest', async () => {
352+
const result = await ldkClient.deleteDebugVersion(
353+
'arn:aws:lambda:us-east-1:123456789012:function:testFunction',
354+
''
355+
)
356+
357+
const result2 = await ldkClient.deleteDebugVersion(
358+
'arn:aws:lambda:us-east-1:123456789012:function:testFunction',
359+
'$LATEST'
360+
)
361+
assert.strictEqual(result, true, 'Should return true without attempting deletion when empty')
362+
assert.strictEqual(result2, true, 'Should return true without attempting deletion when latest')
363+
assert(
364+
mockLambdaClient.deleteFunction.notCalled,
365+
'Should not call deleteFunction when qualifier is empty or latest'
366+
)
367+
})
368+
351369
it('should handle version deletion errors', async () => {
352370
mockLambdaClient.deleteFunction.rejects(new Error('Delete failed'))
353371

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Remote debugging will not delete lambda function by accident if publish version failed"
4+
}

0 commit comments

Comments
 (0)