Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
lola98 committed Mar 8, 2024
1 parent fd1027e commit 5a1d06a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ var ServicesListBeta = mapOf(
"displayName" to "Cloudids",
"path" to "./google-beta/services/cloudids"
),
"cloudquotas" to mapOf(
"name" to "cloudquotas",
"displayName" to "Cloudquotas",
"path" to "./google-beta/services/cloudquotas"
),
"cloudrun" to mapOf(
"name" to "cloudrun",
"displayName" to "Cloudrun",
Expand Down Expand Up @@ -688,4 +693,4 @@ var ServicesListBeta = mapOf(
"displayName" to "Workstations",
"path" to "./google-beta/services/workstations"
)
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ var ServicesListGa = mapOf(
"displayName" to "Cloudids",
"path" to "./google/services/cloudids"
),
"cloudquotas" to mapOf(
"name" to "cloudquotas",
"displayName" to "Cloudquotas",
"path" to "./google/services/cloudquotas"
),
"cloudrun" to mapOf(
"name" to "cloudrun",
"displayName" to "Cloudrun",
Expand Down Expand Up @@ -683,4 +688,4 @@ var ServicesListGa = mapOf(
"displayName" to "Workstations",
"path" to "./google/services/workstations"
)
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package cloudquotas_test

import (
"fmt"
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
Expand All @@ -15,18 +14,23 @@ func TestAccDataSourceGoogleQuotaInfo_basic(t *testing.T) {
t.Parallel()

resourceName := "data.google_cloud_quotas_quota_info.my_quota_info"
project := envvar.GetTestProjectFromEnv()
service := "compute.googleapis.com"
quotaId := "CPUS-per-project-region"

context := map[string]interface{}{
"project": envvar.GetTestProjectFromEnv(),
"service": service,
"quota_id": quotaId,
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
Steps: []resource.TestStep{
{
Config: testAccDataSourceGoogleQuotaInfo_basic(project, service, quotaId),
Config: testAccDataSourceGoogleQuotaInfo_basic(context),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "name", fmt.Sprintf("projects/137295131834/locations/global/services/%s/quotaInfos/%s", service, quotaId)),
resource.TestCheckResourceAttrSet(resourceName, "name"),
resource.TestCheckResourceAttr(resourceName, "quota_id", quotaId),
resource.TestCheckResourceAttr(resourceName, "metric", "compute.googleapis.com/cpus"),
resource.TestCheckResourceAttr(resourceName, "service", service),
Expand All @@ -35,7 +39,7 @@ func TestAccDataSourceGoogleQuotaInfo_basic(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "dimensions.0", "region"),
resource.TestCheckResourceAttr(resourceName, "metric_display_name", "CPUs"),
resource.TestCheckResourceAttr(resourceName, "quota_display_name", "CPUs"),
resource.TestCheckResourceAttr(resourceName, "metric_unit", "1"),
resource.TestCheckResourceAttrSet(resourceName, "metric_unit"),
resource.TestCheckResourceAttrSet(resourceName, "quota_increase_eligibility.0.is_eligible"),
resource.TestCheckResourceAttrSet(resourceName, "dimensions_infos.0.dimensions.region"),
resource.TestCheckResourceAttrSet(resourceName, "dimensions_infos.0.details.0.value"),
Expand All @@ -46,12 +50,12 @@ func TestAccDataSourceGoogleQuotaInfo_basic(t *testing.T) {
})
}

func testAccDataSourceGoogleQuotaInfo_basic(project, service, quota_id string) string {
func testAccDataSourceGoogleQuotaInfo_basic(context map[string]interface{}) string {
return acctest.Nprintf(`
data "google_cloud_quotas_quota_info" "my_quota_info" {
parent = "projects/%{project}"
quota_id = "%{quota_id}"
service = "%{service}"
}
`, map[string]interface{}{"project": project, "service": service, "quota_id": quota_id})
data "google_cloud_quotas_quota_info" "my_quota_info" {
parent = "projects/%{project}"
quota_id = "%{quota_id}"
service = "%{service}"
}
`, context)
}

0 comments on commit 5a1d06a

Please sign in to comment.