diff --git a/.changelog/7344.txt b/.changelog/7344.txt new file mode 100644 index 0000000000..8ec013c069 --- /dev/null +++ b/.changelog/7344.txt @@ -0,0 +1,3 @@ +```release-note:none + +``` diff --git a/google-beta/data_source_google_billing_account_test.go b/google-beta/data_source_google_billing_account_test.go index d57598ed7d..e12b00314e 100644 --- a/google-beta/data_source_google_billing_account_test.go +++ b/google-beta/data_source_google_billing_account_test.go @@ -9,7 +9,7 @@ import ( ) func TestAccDataSourceGoogleBillingAccount_byFullName(t *testing.T) { - billingId := getTestBillingAccountFromEnv(t) + billingId := getTestMasterBillingAccountFromEnv(t) name := "billingAccounts/" + billingId vcrTest(t, resource.TestCase{ @@ -29,7 +29,7 @@ func TestAccDataSourceGoogleBillingAccount_byFullName(t *testing.T) { } func TestAccDataSourceGoogleBillingAccount_byShortName(t *testing.T) { - billingId := getTestBillingAccountFromEnv(t) + billingId := getTestMasterBillingAccountFromEnv(t) name := "billingAccounts/" + billingId vcrTest(t, resource.TestCase{ @@ -49,7 +49,7 @@ func TestAccDataSourceGoogleBillingAccount_byShortName(t *testing.T) { } func TestAccDataSourceGoogleBillingAccount_byFullNameClosed(t *testing.T) { - billingId := getTestBillingAccountFromEnv(t) + billingId := getTestMasterBillingAccountFromEnv(t) name := "billingAccounts/" + billingId vcrTest(t, resource.TestCase{ diff --git a/google-beta/provider_test.go b/google-beta/provider_test.go index b6ff47b7af..23e07efbfe 100644 --- a/google-beta/provider_test.go +++ b/google-beta/provider_test.go @@ -100,6 +100,8 @@ var orgTargetEnvVars = []string{ "GOOGLE_ORG_2", } +// This is the billing account that will be charged for the infrastructure used during testing. For +// that reason, it is also the billing account used for creating new projects. var billingAccountEnvVars = []string{ "GOOGLE_BILLING_ACCOUNT", } @@ -114,6 +116,8 @@ type VcrSource struct { var sources map[string]VcrSource +// This is the billing account that will be modified to test billing-related functionality. It is +// expected to have more permissions granted to the test user and support subaccounts. var masterBillingAccountEnvVars = []string{ "GOOGLE_MASTER_BILLING_ACCOUNT", } @@ -825,11 +829,15 @@ func getTestOrgTargetFromEnv(t *testing.T) string { return MultiEnvSearch(orgTargetEnvVars) } +// This is the billing account that will be charged for the infrastructure used during testing. For +// that reason, it is also the billing account used for creating new projects. func getTestBillingAccountFromEnv(t *testing.T) string { skipIfEnvNotSet(t, billingAccountEnvVars...) return MultiEnvSearch(billingAccountEnvVars) } +// This is the billing account that will be modified to test billing-related functionality. It is +// expected to have more permissions granted to the test user and support subaccounts. func getTestMasterBillingAccountFromEnv(t *testing.T) string { skipIfEnvNotSet(t, masterBillingAccountEnvVars...) return MultiEnvSearch(masterBillingAccountEnvVars) diff --git a/google-beta/resource_google_project_test.go b/google-beta/resource_google_project_test.go index 4450612146..ed7c5ae8fc 100644 --- a/google-beta/resource_google_project_test.go +++ b/google-beta/resource_google_project_test.go @@ -123,6 +123,8 @@ func TestAccProject_create(t *testing.T) { func TestAccProject_billing(t *testing.T) { t.Parallel() org := getTestOrgFromEnv(t) + // This is a second billing account that can be charged, which is used only in this test to + // verify that a project can update its billing account. skipIfEnvNotSet(t, "GOOGLE_BILLING_ACCOUNT_2") billingId2 := os.Getenv("GOOGLE_BILLING_ACCOUNT_2") billingId := getTestBillingAccountFromEnv(t) diff --git a/google-beta/resource_logging_bucket_config_test.go b/google-beta/resource_logging_bucket_config_test.go index fda3da4063..560fdda43d 100644 --- a/google-beta/resource_logging_bucket_config_test.go +++ b/google-beta/resource_logging_bucket_config_test.go @@ -131,7 +131,7 @@ func TestAccLoggingBucketConfigBillingAccount_basic(t *testing.T) { context := map[string]interface{}{ "random_suffix": randString(t, 10), - "billing_account_name": "billingAccounts/" + getTestBillingAccountFromEnv(t), + "billing_account_name": "billingAccounts/" + getTestMasterBillingAccountFromEnv(t), "org_id": getTestOrgFromEnv(t), }