Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address dependency issues in TestAccFirestoreField_* tests #17490

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/9957.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none

```
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"google.golang.org/api/googleapi"

"github.com/hashicorp/terraform-provider-google/google/acctest"
"github.com/hashicorp/terraform-provider-google/google/envvar"
Expand Down Expand Up @@ -231,6 +232,15 @@ func testAccCheckFirestoreFieldDestroyProducer(t *testing.T) func(s *terraform.S
UserAgent: config.UserAgent,
})
if err != nil {
e := err.(*googleapi.Error)
if e.Code == 403 && strings.Contains(e.Message, "Cloud Firestore API has not been used in project") {
// The acceptance test has provisioned the resources under test in a new project, and the destory check is seeing the
// effects of the project not existing. This means the service isn't enabled, and that the resource is definitely destroyed.
// We do not return the error in this case - destroy was successful
return nil
}

// Return err in all other cases
return err
}

Expand Down
8 changes: 6 additions & 2 deletions google/services/firestore/resource_firestore_field_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ resource "google_firestore_database" "database" {
location_id = "nam5"
type = "FIRESTORE_NATIVE"
depends_on = [google_project_service.firestore]
# used to control delete order
depends_on = [
google_project_service.firestore,
google_project.project
]
}
`, context)
} else {
Expand All @@ -117,7 +121,7 @@ resource "google_firestore_database" "database" {
type = "FIRESTORE_NATIVE"
delete_protection_state = "DELETE_PROTECTION_DISABLED"
deletion_policy = "DELETE"
deletion_policy = "DELETE"
}
`, context)
}
Expand Down
Loading