@@ -560,16 +560,38 @@ class TestRunner {
560
560
await this . exec (
561
561
`firebase functions:delete ${ functionName } --project ${ metadata . projectId } --region ${
562
562
metadata . region || DEFAULT_REGION
563
- } --force`,
564
- { silent : true }
563
+ } --force`
565
564
) ;
566
- this . log ( ` ✅ Deleted function via Firebase CLI: ${ functionName } ` , "success" ) ;
567
- deleted = true ;
565
+
566
+ // Verify the function was actually deleted
567
+ this . log ( ` Verifying deletion of ${ functionName } ...` , "info" ) ;
568
+ try {
569
+ const listResult = await this . exec (
570
+ `firebase functions:list --project ${ metadata . projectId } ` ,
571
+ { silent : true }
572
+ ) ;
573
+
574
+ // Check if function still exists in the list
575
+ const functionStillExists = listResult . stdout . includes ( functionName ) ;
576
+
577
+ if ( ! functionStillExists ) {
578
+ this . log ( ` ✅ Verified: Function deleted via Firebase CLI: ${ functionName } ` , "success" ) ;
579
+ deleted = true ;
580
+ } else {
581
+ this . log ( ` ⚠️ Function still exists after Firebase CLI delete: ${ functionName } ` , "warn" ) ;
582
+ }
583
+ } catch ( listError ) {
584
+ // If we can't list functions, assume deletion worked
585
+ this . log ( ` ✅ Deleted function via Firebase CLI (unverified): ${ functionName } ` , "success" ) ;
586
+ deleted = true ;
587
+ }
568
588
} catch ( error ) {
569
589
this . log ( ` ⚠️ Firebase CLI delete failed for ${ functionName } : ${ error . message } ` , "warn" ) ;
590
+ }
570
591
571
- // For v2 functions, if Firebase fails (likely due to missing scheduler job),
572
- // try to delete the Cloud Run service directly
592
+ // If not deleted yet, try alternative methods
593
+ if ( ! deleted ) {
594
+ // For v2 functions, try to delete the Cloud Run service directly
573
595
if ( metadata . projectId === "functions-integration-tests-v2" ) {
574
596
this . log ( ` Attempting Cloud Run service deletion for v2 function...` , "warn" ) ;
575
597
try {
@@ -579,8 +601,22 @@ class TestRunner {
579
601
} --project=${ metadata . projectId } --quiet`,
580
602
{ silent : true }
581
603
) ;
582
- this . log ( ` ✅ Deleted function as Cloud Run service: ${ functionName } ` , "success" ) ;
583
- deleted = true ;
604
+
605
+ // Verify deletion
606
+ try {
607
+ await this . exec (
608
+ `gcloud run services describe ${ functionName } --region=${
609
+ metadata . region || DEFAULT_REGION
610
+ } --project=${ metadata . projectId } `,
611
+ { silent : true }
612
+ ) ;
613
+ // If describe succeeds, function still exists
614
+ this . log ( ` ⚠️ Cloud Run service still exists after deletion: ${ functionName } ` , "warn" ) ;
615
+ } catch {
616
+ // If describe fails, function was deleted
617
+ this . log ( ` ✅ Deleted function as Cloud Run service: ${ functionName } ` , "success" ) ;
618
+ deleted = true ;
619
+ }
584
620
} catch ( runError ) {
585
621
this . log ( ` ⚠️ Cloud Run delete failed: ${ runError . message } ` , "warn" ) ;
586
622
}
@@ -595,8 +631,23 @@ class TestRunner {
595
631
} --project=${ metadata . projectId } --quiet`,
596
632
{ silent : true }
597
633
) ;
598
- this . log ( ` ✅ Deleted function via gcloud: ${ functionName } ` , "success" ) ;
599
- deleted = true ;
634
+
635
+ // Verify deletion
636
+ try {
637
+ await this . exec (
638
+ `gcloud functions describe ${ functionName } --region=${
639
+ metadata . region || DEFAULT_REGION
640
+ } --project=${ metadata . projectId } `,
641
+ { silent : true }
642
+ ) ;
643
+ // If describe succeeds, function still exists
644
+ this . log ( ` ⚠️ Function still exists after gcloud delete: ${ functionName } ` , "warn" ) ;
645
+ deleted = false ;
646
+ } catch {
647
+ // If describe fails, function was deleted
648
+ this . log ( ` ✅ Deleted function via gcloud: ${ functionName } ` , "success" ) ;
649
+ deleted = true ;
650
+ }
600
651
} catch ( e ) {
601
652
this . log ( ` ❌ Failed to delete function ${ functionName } via any method` , "error" ) ;
602
653
this . log ( ` Last error: ${ e . message } ` , "error" ) ;
0 commit comments