Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: billing budget tests #594

Merged
merged 1 commit into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions test/fixtures/budget/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ output "project_id" {
value = module.budget.project_id
}

output "billing_account" {
description = "The billing account where budgets are created"
value = var.billing_account
}

output "parent_project_id" {
description = "The project_id of the parent project to add as an additional project for the budget"
value = module.budget.parent_project_id
Expand Down
11 changes: 5 additions & 6 deletions test/integration/budget/controls/budget.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

project_id = attribute("project_id")
billing_account = attribute("billing_account")
parent_project_id = attribute("parent_project_id")
pubsub_topic = attribute("pubsub_topic")
main_budget_name = attribute("main_budget_name")
Expand Down Expand Up @@ -45,8 +46,7 @@
control "project-factory-budget-main" do
title "Main Budget"

# Budgets is only available via rest api currently
describe command("curl -s -X GET -H \"Authorization: Bearer \"`gcloud auth print-access-token` https://billingbudgets.googleapis.com/v1beta1/#{main_budget_name}") do
describe command("gcloud alpha billing budgets describe #{main_budget_name} --billing-account=#{billing_account} --format=json") do
its("exit_status") { should be 0 }
its("stderr") { should eq "" }

Expand All @@ -60,7 +60,7 @@

it "has expected structure" do
expect(metadata).to match(hash_including({
name: main_budget_name,
name: "billingAccounts/#{billing_account}/budgets/#{main_budget_name}",
displayName: "Budget For #{project_id}",
budgetFilter: hash_including({creditTypesTreatment: "INCLUDE_ALL_CREDITS"}),
amount: hash_including({specifiedAmount: hash_including({units: "#{budget_amount}"})}),
Expand All @@ -78,8 +78,7 @@
control "project-factory-budget-additional" do
title "Additional Budget"

# Budgets is only available via rest api currently
describe command("curl -s -X GET -H \"Authorization: Bearer \"`gcloud auth print-access-token` https://billingbudgets.googleapis.com/v1beta1/#{additional_budget_name}") do
describe command("gcloud alpha billing budgets describe #{additional_budget_name} --billing-account=#{billing_account} --format=json") do
its("exit_status") { should be 0 }
its("stderr") { should eq "" }

Expand All @@ -93,7 +92,7 @@

it "has expected structure" do
expect(metadata).to match(hash_including({
name: additional_budget_name,
name: "billingAccounts/#{billing_account}/budgets/#{additional_budget_name}",
displayName: "CI/CD Budget for #{project_id}",
budgetFilter: hash_including({creditTypesTreatment: budget_credit_types_treatment}),
amount: hash_including({specifiedAmount: hash_including({units: "#{budget_amount}"})}),
Expand Down
3 changes: 3 additions & 0 deletions test/integration/budget/inspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ attributes:
- name: project_id
required: true

- name: billing_account
required: true

- name: parent_project_id
required: true

Expand Down