summaryrefslogtreecommitdiff
path: root/spec/services/check_gcp_project_billing_service_spec.rb
blob: 3e68d906e71f3639384bbc3a109840f4fdfbe958 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'spec_helper'

describe CheckGcpProjectBillingService do
  include GoogleApi::CloudPlatformHelpers

  let(:service) { described_class.new }
  let(:project_id) { 'test-project-1234' }

  describe '#execute' do
    before do
      stub_cloud_platform_projects_list(project_id: project_id)
    end

    subject { service.execute('bogustoken') }

    context 'google account has a billing enabled gcp project' do
      before do
        stub_cloud_platform_projects_get_billing_info(project_id, true)
      end

      it { is_expected.to all(satisfy { |project| project.project_id == project_id }) }
    end

    context 'google account does not have a billing enabled gcp project' do
      before do
        stub_cloud_platform_projects_get_billing_info(project_id, false)
      end

      it { is_expected.to eq([]) }
    end
  end
end