@@ -60,6 +60,13 @@ func TestLambdaPhysicalResourceId(t *testing.T) {
6060 // For Delete with returned PhysicalResourceID = old PhysicalResourceID
6161 {RequestDelete , nil , "prevPhysicalResourceID" , "prevPhysicalResourceID" },
6262 {RequestDelete , fmt .Errorf ("dummy error" ), "prevPhysicalResourceID" , "prevPhysicalResourceID" },
63+
64+ // For Delete with returned PhysicalResourceID != old PhysicalResourceID
65+ // Technically, lambda handlers shouldn't return a different physical resource id upon deletion.
66+ // Typescript CDK implementation for handlers would return an error here.
67+ // But CFn ignores the returned PhysicalResourceID for deletion (if deletion succeeds) so it doesn't matter.
68+ {RequestDelete , nil , "newPhysicalResourceID" , "newPhysicalResourceID" },
69+ {RequestDelete , fmt .Errorf ("dummy error" ), "newPhysicalResourceID" , "newPhysicalResourceID" },
6370 }
6471 for _ , test := range tests {
6572
@@ -99,36 +106,6 @@ func TestLambdaPhysicalResourceId(t *testing.T) {
99106 }
100107}
101108
102- func TestDeleteFailsWhenPhysicalResourceIDChanges (t * testing.T ) {
103-
104- curTestEvent := * testEvent
105- curTestEvent .RequestType = RequestDelete
106-
107- client := & mockClient {
108- DoFunc : func (req * http.Request ) (* http.Response , error ) {
109- response := extractResponseBody (t , req )
110-
111- // Status should be Failed because the PhysicalResourceID changed
112- assert .Equal (t , StatusFailed , response .Status )
113- assert .Equal (t , curTestEvent .LogicalResourceID , response .LogicalResourceID )
114- assert .Equal (t , "newPhysicalResourceID" , response .PhysicalResourceID )
115-
116- return & http.Response {
117- StatusCode : http .StatusOK ,
118- Body : nopCloser {bytes .NewBufferString ("" )},
119- }, nil
120- },
121- }
122-
123- fn := func (ctx context.Context , event Event ) (physicalResourceID string , data map [string ]interface {}, err error ) {
124- return "newPhysicalResourceID" , nil , nil // No error but a "newPhysicalResourceID" is returned
125- }
126-
127- _ , err := lambdaWrapWithClient (fn , client )(context .TODO (), curTestEvent )
128- assert .NoError (t , err )
129-
130- }
131-
132109func TestPanicSendsFailure (t * testing.T ) {
133110 didSendStatus := false
134111
0 commit comments