forked from hashicorp/terraform-provider-google-beta
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdata_source_alloydb_database_instance_test.go
65 lines (55 loc) · 1.77 KB
/
data_source_alloydb_database_instance_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package alloydb_test
import (
"testing"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest"
)
func TestAccAlloydbDatabaseInstanceDatasourceConfig(t *testing.T) {
t.Parallel()
context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
"network_name": acctest.BootstrapSharedServiceNetworkingConnection(t, "alloydb-instance-mandatory-1"),
}
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckAlloydbInstanceDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccAlloydbDatabaseInstanceDatasourceConfig(context),
},
},
})
}
func testAccAlloydbDatabaseInstanceDatasourceConfig(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_alloydb_instance" "default" {
cluster = google_alloydb_cluster.default.name
instance_id = "tf-test-alloydb-instance%{random_suffix}"
instance_type = "PRIMARY"
machine_config {
cpu_count = 2
}
}
resource "google_alloydb_cluster" "default" {
cluster_id = "tf-test-alloydb-cluster%{random_suffix}"
location = "us-central1"
network_config {
network = data.google_compute_network.default.id
}
initial_user {
password = "tf-test-alloydb-cluster%{random_suffix}"
}
}
data "google_compute_network" "default" {
name = "%{network_name}"
}
data "google_alloydb_instance" "default" {
cluster_id = google_alloydb_cluster.default.cluster_id
instance_id = google_alloydb_instance.default.instance_id
location = "us-central1"
}
`, context)
}