|
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | 15 | project_id = attribute("project_id") |
| 16 | +billing_account = attribute("billing_account") |
16 | 17 | parent_project_id = attribute("parent_project_id") |
17 | 18 | pubsub_topic = attribute("pubsub_topic") |
18 | 19 | main_budget_name = attribute("main_budget_name") |
|
45 | 46 | control "project-factory-budget-main" do |
46 | 47 | title "Main Budget" |
47 | 48 |
|
48 | | - # Budgets is only available via rest api currently |
49 | | - describe command("curl -s -X GET -H \"Authorization: Bearer \"`gcloud auth print-access-token` https://billingbudgets.googleapis.com/v1beta1/#{main_budget_name}") do |
| 49 | + describe command("gcloud alpha billing budgets describe #{main_budget_name} --billing-account=#{billing_account} --format=json") do |
50 | 50 | its("exit_status") { should be 0 } |
51 | 51 | its("stderr") { should eq "" } |
52 | 52 |
|
|
60 | 60 |
|
61 | 61 | it "has expected structure" do |
62 | 62 | expect(metadata).to match(hash_including({ |
63 | | - name: main_budget_name, |
| 63 | + name: "billingAccounts/#{billing_account}/budgets/#{main_budget_name}", |
64 | 64 | displayName: "Budget For #{project_id}", |
65 | 65 | budgetFilter: hash_including({creditTypesTreatment: "INCLUDE_ALL_CREDITS"}), |
66 | 66 | amount: hash_including({specifiedAmount: hash_including({units: "#{budget_amount}"})}), |
|
78 | 78 | control "project-factory-budget-additional" do |
79 | 79 | title "Additional Budget" |
80 | 80 |
|
81 | | - # Budgets is only available via rest api currently |
82 | | - describe command("curl -s -X GET -H \"Authorization: Bearer \"`gcloud auth print-access-token` https://billingbudgets.googleapis.com/v1beta1/#{additional_budget_name}") do |
| 81 | + describe command("gcloud alpha billing budgets describe #{additional_budget_name} --billing-account=#{billing_account} --format=json") do |
83 | 82 | its("exit_status") { should be 0 } |
84 | 83 | its("stderr") { should eq "" } |
85 | 84 |
|
|
93 | 92 |
|
94 | 93 | it "has expected structure" do |
95 | 94 | expect(metadata).to match(hash_including({ |
96 | | - name: additional_budget_name, |
| 95 | + name: "billingAccounts/#{billing_account}/budgets/#{additional_budget_name}", |
97 | 96 | displayName: "CI/CD Budget for #{project_id}", |
98 | 97 | budgetFilter: hash_including({creditTypesTreatment: budget_credit_types_treatment}), |
99 | 98 | amount: hash_including({specifiedAmount: hash_including({units: "#{budget_amount}"})}), |
|
0 commit comments