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

resource_group_spec.rb « build « seed « pipeline « ci « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8fcc242ba5ffa7fac47b1cb0028c7c9503b9e244 (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
39
40
41
42
43
44
45
46
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Ci::Pipeline::Seed::Build::ResourceGroup do
  let_it_be(:project) { create(:project) }
  let(:job) { build(:ci_build, project: project) }
  let(:seed) { described_class.new(job, resource_group_key) }

  describe '#to_resource' do
    subject { seed.to_resource }

    context 'when resource group key is specified' do
      let(:resource_group_key) { 'iOS' }

      it 'returns a resource group object' do
        is_expected.to be_a(Ci::ResourceGroup)
        expect(subject.key).to eq('iOS')
      end

      context 'when environment has an invalid URL' do
        let(:resource_group_key) { ':::' }

        it 'returns nothing' do
          is_expected.to be_nil
        end
      end

      context 'when there is a resource group already' do
        let!(:resource_group) { create(:ci_resource_group, project: project, key: 'iOS') }

        it 'does not create a new resource group' do
          expect { subject }.not_to change { Ci::ResourceGroup.count }
        end
      end
    end

    context 'when resource group key is nil' do
      let(:resource_group_key) { nil }

      it 'returns nothing' do
        is_expected.to be_nil
      end
    end
  end
end