@@ -827,6 +827,7 @@ class TestRunner {
827
827
// Function names from firebase functions:list are just the name, no region suffix
828
828
const functionName = func . trim ( ) ;
829
829
const region = DEFAULT_REGION ;
830
+ let deleted = false ;
830
831
831
832
this . log ( ` Deleting function: ${ functionName } in region: ${ region } ` , "warn" ) ;
832
833
@@ -836,22 +837,64 @@ class TestRunner {
836
837
`firebase functions:delete ${ functionName } --project ${ projectId } --region ${ region } --force` ,
837
838
{ silent : true }
838
839
) ;
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
+ }
840
863
} 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" ) ;
843
870
try {
844
871
await this . exec (
845
872
`gcloud functions delete ${ functionName } --region=${ region } --project=${ projectId } --quiet` ,
846
873
{ silent : true }
847
874
) ;
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
+ }
849
889
} catch ( gcloudError ) {
850
890
this . log ( ` ❌ Failed to delete: ${ functionName } ` , "error" ) ;
851
- this . log ( ` Firebase error: ${ firebaseError . message } ` , "error" ) ;
852
891
this . log ( ` Gcloud error: ${ gcloudError . message } ` , "error" ) ;
853
892
}
854
893
}
894
+
895
+ if ( ! deleted ) {
896
+ this . log ( ` ❌ Failed to delete function ${ functionName } via any method` , "error" ) ;
897
+ }
855
898
} catch ( e ) {
856
899
this . log ( ` ❌ Unexpected error deleting ${ func } : ${ e . message } ` , "error" ) ;
857
900
}
0 commit comments