Skip to content

Commit

Permalink
fix diff on currency_code in google_billing_budget (#4405) (#8266)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
modular-magician authored Jan 21, 2021
1 parent ffe1bdb commit 238a4b4
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/4405.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
billing: fixed perma-diff on currency_code in `google_billing_budget`
```
1 change: 1 addition & 0 deletions google/resource_billing_budget.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
},
Expand Down
65 changes: 65 additions & 0 deletions google/resource_billing_budget_test.go
Original file line number Diff line number Diff line change
@@ -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)
}

0 comments on commit 238a4b4

Please sign in to comment.