Skip to content

Commit 8a0013b

Browse files
test: Fix missing database for datastore_index test. (#10316) (#17770)
[upstream:e040a9334c923903a7180deec51aa96113181354] Signed-off-by: Modular Magician <[email protected]>
1 parent 748a387 commit 8a0013b

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

.changelog/10316.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:none
2+
3+
```

google/services/datastore/resource_datastore_index_generated_test.go

+17
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
2727

2828
"github.com/hashicorp/terraform-provider-google/google/acctest"
29+
"github.com/hashicorp/terraform-provider-google/google/envvar"
2930
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
3031
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
3132
)
@@ -34,6 +35,7 @@ func TestAccDatastoreIndex_datastoreIndexExample(t *testing.T) {
3435
t.Parallel()
3536

3637
context := map[string]interface{}{
38+
"project_id": envvar.GetTestProjectFromEnv(),
3739
"random_suffix": acctest.RandString(t, 10),
3840
}
3941

@@ -56,6 +58,19 @@ func TestAccDatastoreIndex_datastoreIndexExample(t *testing.T) {
5658

5759
func testAccDatastoreIndex_datastoreIndexExample(context map[string]interface{}) string {
5860
return acctest.Nprintf(`
61+
resource "google_firestore_database" "database" {
62+
project = "%{project_id}"
63+
# google_datastore_index resources only support the (default) database.
64+
# However, google_firestore_index can express any Datastore Mode index
65+
# and should be preferred in all cases.
66+
name = "(default)"
67+
location_id = "nam5"
68+
type = "DATASTORE_MODE"
69+
70+
delete_protection_state = "DELETE_PROTECTION_DISABLED"
71+
deletion_policy = "DELETE"
72+
}
73+
5974
resource "google_datastore_index" "default" {
6075
kind = "foo"
6176
properties {
@@ -66,6 +81,8 @@ resource "google_datastore_index" "default" {
6681
name = "tf_test_property_b%{random_suffix}"
6782
direction = "ASCENDING"
6883
}
84+
85+
depends_on = [google_firestore_database.database]
6986
}
7087
`, context)
7188
}

website/docs/r/datastore_index.html.markdown

+15-5
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,23 @@ one, you can create a `google_app_engine_application` resource with
3434
`database_type` set to `"CLOUD_DATASTORE_COMPATIBILITY"` to do so. Your
3535
Datastore location will be the same as the App Engine location specified.
3636

37-
<div class = "oics-button" style="float: right; margin: 0 0 -15px">
38-
<a href="https://console.cloud.google.com/cloudshell/open?cloudshell_git_repo=https%3A%2F%2Fgithub.jpy.wang%2Fterraform-google-modules%2Fdocs-examples.git&cloudshell_working_dir=datastore_index&cloudshell_image=gcr.io%2Fcloudshell-images%2Fcloudshell%3Alatest&open_in_editor=main.tf&cloudshell_print=.%2Fmotd&cloudshell_tutorial=.%2Ftutorial.md" target="_blank">
39-
<img alt="Open in Cloud Shell" src="//gstatic.com/cloudssh/images/open-btn.svg" style="max-height: 44px; margin: 32px auto; max-width: 100%;">
40-
</a>
41-
</div>
4237
## Example Usage - Datastore Index
4338

4439

4540
```hcl
41+
resource "google_firestore_database" "database" {
42+
project = "my-project-name"
43+
# google_datastore_index resources only support the (default) database.
44+
# However, google_firestore_index can express any Datastore Mode index
45+
# and should be preferred in all cases.
46+
name = "(default)"
47+
location_id = "nam5"
48+
type = "DATASTORE_MODE"
49+
50+
delete_protection_state = "DELETE_PROTECTION_DISABLED"
51+
deletion_policy = "DELETE"
52+
}
53+
4654
resource "google_datastore_index" "default" {
4755
kind = "foo"
4856
properties {
@@ -53,6 +61,8 @@ resource "google_datastore_index" "default" {
5361
name = "property_b"
5462
direction = "ASCENDING"
5563
}
64+
65+
depends_on = [google_firestore_database.database]
5666
}
5767
```
5868

0 commit comments

Comments
 (0)