From 038f3b0bb5dc1dc438f2669a35680f69fc510c62 Mon Sep 17 00:00:00 2001 From: Bob Hogg Date: Wed, 8 Jul 2026 12:05:46 -0400 Subject: [PATCH] test: Fix flaky Firestore Timestamp field test Tests were failing because they incorrectly interpreted a 404 on the project or database as indicating the field might still be around. This can happen if the database is deleted before we check if the timestamp field still exists. --- .../terraform/custom_check_destroy/firestore_field.go.tmpl | 4 ++++ .../terraform/samples/base_configs/test_file.go.tmpl | 2 ++ 2 files changed, 6 insertions(+) diff --git a/mmv1/templates/terraform/custom_check_destroy/firestore_field.go.tmpl b/mmv1/templates/terraform/custom_check_destroy/firestore_field.go.tmpl index b2eb939c523c..c1ec2ba712d3 100644 --- a/mmv1/templates/terraform/custom_check_destroy/firestore_field.go.tmpl +++ b/mmv1/templates/terraform/custom_check_destroy/firestore_field.go.tmpl @@ -23,6 +23,10 @@ if err != nil { // We do not return the error in this case - destroy was successful return nil } + if e.Code == 404 && regexp.MustCompile(`Project .* or database .* does not exist`).MatchString(e.Message) { + // The project or database does not exist, which means the resource is destroyed. + return nil + } // Return err in all other cases return err diff --git a/mmv1/templates/terraform/samples/base_configs/test_file.go.tmpl b/mmv1/templates/terraform/samples/base_configs/test_file.go.tmpl index 86a7d2524c6b..9cca626dea12 100644 --- a/mmv1/templates/terraform/samples/base_configs/test_file.go.tmpl +++ b/mmv1/templates/terraform/samples/base_configs/test_file.go.tmpl @@ -28,6 +28,7 @@ package {{ $.Res.PackageName }}_test import ( "fmt" "log" + "regexp" "strconv" "strings" "testing" @@ -59,6 +60,7 @@ import ( var ( _ = fmt.Sprintf _ = log.Print + _ = regexp.MatchString _ = strconv.Atoi _ = strings.Trim _ = time.Now