From 238a4b4284ca2dbcde0c5dcdfebec5290eabc2b2 Mon Sep 17 00:00:00 2001 From: The Magician Date: Thu, 21 Jan 2021 07:40:34 -0800 Subject: [PATCH] fix diff on currency_code in google_billing_budget (#4405) (#8266) * fix diff on currency_code * add a test for leaving currency_code blank * Update resource_billing_budget_test.go * Update resource_billing_budget_test.go Signed-off-by: Modular Magician --- .changelog/4405.txt | 3 ++ google/resource_billing_budget.go | 1 + google/resource_billing_budget_test.go | 65 ++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 .changelog/4405.txt create mode 100644 google/resource_billing_budget_test.go diff --git a/.changelog/4405.txt b/.changelog/4405.txt new file mode 100644 index 00000000000..b5efe203816 --- /dev/null +++ b/.changelog/4405.txt @@ -0,0 +1,3 @@ +```release-note:bug +billing: fixed perma-diff on currency_code in `google_billing_budget` +``` diff --git a/google/resource_billing_budget.go b/google/resource_billing_budget.go index 83887753825..9dec13c6df9 100644 --- a/google/resource_billing_budget.go +++ b/google/resource_billing_budget.go @@ -66,6 +66,7 @@ billing account. The currencyCode is provided on output.`, Schema: map[string]*schema.Schema{ "currency_code": { Type: schema.TypeString, + Computed: true, Optional: true, Description: `The 3-letter currency code defined in ISO 4217.`, }, diff --git a/google/resource_billing_budget_test.go b/google/resource_billing_budget_test.go new file mode 100644 index 00000000000..c0f68323059 --- /dev/null +++ b/google/resource_billing_budget_test.go @@ -0,0 +1,65 @@ +package google + +import ( + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccBillingBudget_billingBudgetCurrencycode(t *testing.T) { + t.Parallel() + + context := map[string]interface{}{ + "billing_acct": getTestBillingAccountFromEnv(t), + "random_suffix": randString(t, 10), + } + + vcrTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + ExternalProviders: map[string]resource.ExternalProvider{ + "random": {}, + }, + CheckDestroy: testAccCheckBillingBudgetDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccBillingBudget_billingBudgetCurrencycode(context), + Check: resource.ComposeTestCheckFunc(), + }, + }, + }) +} + +func testAccBillingBudget_billingBudgetCurrencycode(context map[string]interface{}) string { + return Nprintf(` +data "google_billing_account" "account" { + billing_account = "%{billing_acct}" +} + +data "google_project" "project" { +} + +resource "google_billing_budget" "budget" { + billing_account = data.google_billing_account.account.id + display_name = "Example Billing Budget%{random_suffix}" + + budget_filter { + projects = ["projects/${data.google_project.project.number}"] + } + + amount { + specified_amount { + units = "100000" + } + } + + threshold_rules { + threshold_percent = 1.0 + } + threshold_rules { + threshold_percent = 1.0 + spend_basis = "FORECASTED_SPEND" + } +} +`, context) +}