Welcome to mirror list, hosted at ThFree Co, Russian Federation.

enable_vision_ai_service_spec.rb « google_cloud « cloud_seed « services « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c37b5681a4b70b76e1553d851c3a3608fae679d0 (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
33
34
35
36
37
38
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe CloudSeed::GoogleCloud::EnableVisionAiService, feature_category: :deployment_management do
  describe 'when a project does not have any gcp projects' do
    let_it_be(:project) { create(:project) }

    it 'returns error' do
      result = described_class.new(project).execute
      message = 'No GCP projects found. Configure a service account or GCP_PROJECT_ID ci variable.'

      expect(result[:status]).to eq(:error)
      expect(result[:message]).to eq(message)
    end
  end

  describe 'when a project has 3 gcp projects' do
    let_it_be(:project) { create(:project) }

    before do
      project.variables.build(environment_scope: 'production', key: 'GCP_PROJECT_ID', value: 'prj-prod')
      project.variables.build(environment_scope: 'staging', key: 'GCP_PROJECT_ID', value: 'prj-staging')
      project.save!
    end

    it 'enables cloud run, artifacts registry and cloud build', :aggregate_failures do
      expect_next_instance_of(GoogleApi::CloudPlatform::Client) do |instance|
        expect(instance).to receive(:enable_vision_api).with('prj-prod')
        expect(instance).to receive(:enable_vision_api).with('prj-staging')
      end

      result = described_class.new(project).execute

      expect(result[:status]).to eq(:success)
    end
  end
end