gitlab-org--gitlab-foss/spec/services/check_gcp_project_billing_s...

32 lines
1001 B
Ruby
Raw Normal View History

2017-12-16 00:44:36 +00:00
require 'spec_helper'
2017-12-16 01:12:44 +00:00
describe CheckGcpProjectBillingService do
2017-12-16 00:44:36 +00:00
let(:service) { described_class.new }
2018-01-11 00:29:35 +00:00
let(:projects) { [double(name: 'first_project', project_id: 'first_project-1234'), double(name: 'second_project', project_id: 'second_project-1234')] }
2017-12-16 00:44:36 +00:00
describe '#execute' do
before do
expect_any_instance_of(GoogleApi::CloudPlatform::Client)
.to receive(:projects_list).and_return(projects)
2017-12-16 00:44:36 +00:00
allow_any_instance_of(GoogleApi::CloudPlatform::Client)
2018-01-11 00:29:35 +00:00
.to receive_message_chain(:projects_get_billing_info, :billing_enabled)
2017-12-16 00:44:36 +00:00
.and_return(project_billing_enabled)
end
subject { service.execute('bogustoken') }
context 'google account has a billing enabled gcp project' do
let(:project_billing_enabled) { true }
it { is_expected.to eq(projects) }
2017-12-16 00:44:36 +00:00
end
context 'google account does not have a billing enabled gcp project' do
let(:project_billing_enabled) { false }
it { is_expected.to eq([]) }
2017-12-16 00:44:36 +00:00
end
end
end