@@ -827,6 +827,7 @@ class TestRunner {
827827            // Function names from firebase functions:list are just the name, no region suffix 
828828            const  functionName  =  func . trim ( ) ; 
829829            const  region  =  DEFAULT_REGION ; 
830+             let  deleted  =  false ; 
830831
831832            this . log ( `   Deleting function: ${ functionName }   in region: ${ region }  ` ,  "warn" ) ; 
832833
@@ -836,22 +837,64 @@ class TestRunner {
836837                `firebase functions:delete ${ functionName }   --project ${ projectId }   --region ${ region }   --force` , 
837838                {  silent : true  } 
838839              ) ; 
839-               this . log ( `   ✅ Deleted via Firebase CLI: ${ functionName }  ` ) ; 
840+ 
841+               // Verify the function was actually deleted 
842+               this . log ( `   Verifying deletion of ${ functionName }  ...` ,  "info" ) ; 
843+               try  { 
844+                 const  listResult  =  await  this . exec ( 
845+                   `firebase functions:list --project ${ projectId }  ` , 
846+                   {  silent : true  } 
847+                 ) ; 
848+ 
849+                 // Check if function still exists in the list 
850+                 const  functionStillExists  =  listResult . stdout . includes ( functionName ) ; 
851+ 
852+                 if  ( ! functionStillExists )  { 
853+                   this . log ( `   ✅ Verified: Function deleted via Firebase CLI: ${ functionName }  ` ,  "success" ) ; 
854+                   deleted  =  true ; 
855+                 }  else  { 
856+                   this . log ( `   ⚠️ Function still exists after Firebase CLI delete: ${ functionName }  ` ,  "warn" ) ; 
857+                 } 
858+               }  catch  ( listError )  { 
859+                 // If we can't list functions, assume deletion worked 
860+                 this . log ( `   ✅ Deleted via Firebase CLI (unverified): ${ functionName }  ` ,  "success" ) ; 
861+                 deleted  =  true ; 
862+               } 
840863            }  catch  ( firebaseError )  { 
841-               // If Firebase CLI fails, try gcloud as fallback 
842-               this . log ( `   Firebase CLI failed, trying gcloud for: ${ functionName }  ` ,  "warn" ) ; 
864+               this . log ( `   ⚠️ Firebase CLI delete failed for ${ functionName }  : ${ firebaseError . message }  ` ,  "warn" ) ; 
865+             } 
866+ 
867+             // If not deleted yet, try gcloud as fallback 
868+             if  ( ! deleted )  { 
869+               this . log ( `   Trying gcloud for: ${ functionName }  ` ,  "warn" ) ; 
843870              try  { 
844871                await  this . exec ( 
845872                  `gcloud functions delete ${ functionName }   --region=${ region }   --project=${ projectId }   --quiet` , 
846873                  {  silent : true  } 
847874                ) ; 
848-                 this . log ( `   ✅ Deleted via gcloud: ${ functionName }  ` ) ; 
875+ 
876+                 // Verify deletion 
877+                 try  { 
878+                   await  this . exec ( 
879+                     `gcloud functions describe ${ functionName }   --region=${ region }   --project=${ projectId }  ` , 
880+                     {  silent : true  } 
881+                   ) ; 
882+                   // If describe succeeds, function still exists 
883+                   this . log ( `   ⚠️ Function still exists after gcloud delete: ${ functionName }  ` ,  "warn" ) ; 
884+                 }  catch  { 
885+                   // If describe fails, function was deleted 
886+                   this . log ( `   ✅ Deleted via gcloud: ${ functionName }  ` ,  "success" ) ; 
887+                   deleted  =  true ; 
888+                 } 
849889              }  catch  ( gcloudError )  { 
850890                this . log ( `   ❌ Failed to delete: ${ functionName }  ` ,  "error" ) ; 
851-                 this . log ( `   Firebase error: ${ firebaseError . message }  ` ,  "error" ) ; 
852891                this . log ( `   Gcloud error: ${ gcloudError . message }  ` ,  "error" ) ; 
853892              } 
854893            } 
894+ 
895+             if  ( ! deleted )  { 
896+               this . log ( `   ❌ Failed to delete function ${ functionName }   via any method` ,  "error" ) ; 
897+             } 
855898          }  catch  ( e )  { 
856899            this . log ( `   ❌ Unexpected error deleting ${ func }  : ${ e . message }  ` ,  "error" ) ; 
857900          } 
0 commit comments