2017-12-15 19:44:36 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-12-15 20:12:44 -05:00
|
|
|
describe CheckGcpProjectBillingService do
|
2018-01-11 01:14:08 -05:00
|
|
|
include GoogleApi::CloudPlatformHelpers
|
|
|
|
|
2017-12-15 19:44:36 -05:00
|
|
|
let(:service) { described_class.new }
|
2018-01-11 01:14:08 -05:00
|
|
|
let(:project_id) { 'test-project-1234' }
|
2017-12-15 19:44:36 -05:00
|
|
|
|
|
|
|
describe '#execute' do
|
|
|
|
before do
|
2018-01-11 01:14:08 -05:00
|
|
|
stub_cloud_platform_projects_list(project_id: project_id)
|
2017-12-15 19:44:36 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
subject { service.execute('bogustoken') }
|
|
|
|
|
|
|
|
context 'google account has a billing enabled gcp project' do
|
2018-01-11 01:14:08 -05:00
|
|
|
before do
|
|
|
|
stub_cloud_platform_projects_get_billing_info(project_id, true)
|
|
|
|
end
|
2017-12-15 19:44:36 -05:00
|
|
|
|
2018-01-11 01:14:08 -05:00
|
|
|
it { is_expected.to all(satisfy { |project| project.project_id == project_id }) }
|
2017-12-15 19:44:36 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'google account does not have a billing enabled gcp project' do
|
2018-01-11 01:14:08 -05:00
|
|
|
before do
|
|
|
|
stub_cloud_platform_projects_get_billing_info(project_id, false)
|
|
|
|
end
|
2017-12-15 19:44:36 -05:00
|
|
|
|
2018-01-04 18:35:19 -05:00
|
|
|
it { is_expected.to eq([]) }
|
2017-12-15 19:44:36 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|