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

33 lines
842 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
2018-01-11 06:14:08 +00:00
include GoogleApi::CloudPlatformHelpers
2017-12-16 00:44:36 +00:00
let(:service) { described_class.new }
2018-01-11 06:14:08 +00:00
let(:project_id) { 'test-project-1234' }
2017-12-16 00:44:36 +00:00
describe '#execute' do
before do
2018-01-11 06:14:08 +00:00
stub_cloud_platform_projects_list(project_id: project_id)
2017-12-16 00:44:36 +00:00
end
subject { service.execute('bogustoken') }
context 'google account has a billing enabled gcp project' do
2018-01-11 06:14:08 +00:00
before do
stub_cloud_platform_projects_get_billing_info(project_id, true)
end
2017-12-16 00:44:36 +00:00
2018-01-11 06:14:08 +00:00
it { is_expected.to all(satisfy { |project| project.project_id == project_id }) }
2017-12-16 00:44:36 +00:00
end
context 'google account does not have a billing enabled gcp project' do
2018-01-11 06:14:08 +00:00
before do
stub_cloud_platform_projects_get_billing_info(project_id, false)
end
2017-12-16 00:44:36 +00:00
it { is_expected.to eq([]) }
2017-12-16 00:44:36 +00:00
end
end
end