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

normalizer_spec.rb « mapper « external « config « ci « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 09212833d84f22b27b74c51f2d6f4f9dcac239e6 (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
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Ci::Config::External::Mapper::Normalizer, feature_category: :pipeline_composition do
  let_it_be(:variables) do
    Gitlab::Ci::Variables::Collection.new.tap do |variables|
      variables.append(key: 'VARIABLE1', value: 'config')
      variables.append(key: 'VARIABLE2', value: 'https://example.com')
    end
  end

  let_it_be(:context) do
    Gitlab::Ci::Config::External::Context.new(variables: variables)
  end

  subject(:normalizer) { described_class.new(context) }

  describe '#process' do
    let(:locations) do
      ['https://example.com/.gitlab-ci.yml',
       'config/.gitlab-ci.yml',
       { local: 'config/.gitlab-ci.yml' },
       { remote: 'https://example.com/.gitlab-ci.yml' },
       { template: 'Template.gitlab-ci.yml' },
       '$VARIABLE1/.gitlab-ci.yml',
       '$VARIABLE2/.gitlab-ci.yml']
    end

    subject(:process) { normalizer.process(locations) }

    it 'converts locations to canonical form' do
      is_expected.to eq(
        [{ remote: 'https://example.com/.gitlab-ci.yml' },
         { local: 'config/.gitlab-ci.yml' },
         { local: 'config/.gitlab-ci.yml' },
         { remote: 'https://example.com/.gitlab-ci.yml' },
         { template: 'Template.gitlab-ci.yml' },
         { local: 'config/.gitlab-ci.yml' },
         { remote: 'https://example.com/.gitlab-ci.yml' }]
      )
    end
  end
end