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

interruptible_spec.rb « test_cases « yaml_processor « ci « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 03ff7077969fc10453b39ed8b10a82dbb804b56b (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# frozen_string_literal: true

require 'spec_helper'

module Gitlab
  module Ci
    RSpec.describe YamlProcessor, feature_category: :pipeline_composition do
      subject(:processor) { described_class.new(config, user: nil).execute }

      let(:builds) { processor.builds }

      context 'with interruptible' do
        let(:default_config) { nil }

        let(:config) do
          <<~YAML
            #{default_config}

            build1:
              script: rspec
              interruptible: true

            build2:
              script: rspec
              interruptible: false

            build3:
              script: rspec

            bridge1:
              trigger: some/project
              interruptible: true

            bridge2:
              trigger: some/project
              interruptible: false

            bridge3:
              trigger: some/project
          YAML
        end

        it 'returns jobs with their interruptible value' do
          expect(builds).to contain_exactly(
            a_hash_including(name: 'build1', interruptible: true),
            a_hash_including(name: 'build2', interruptible: false),
            a_hash_including(name: 'build3').and(exclude(:interruptible)),
            a_hash_including(name: 'bridge1', interruptible: true),
            a_hash_including(name: 'bridge2', interruptible: false),
            a_hash_including(name: 'bridge3').and(exclude(:interruptible))
          )
        end

        context 'when default:interruptible is true' do
          let(:default_config) do
            <<~YAML
              default:
                interruptible: true
            YAML
          end

          it 'returns jobs with their interruptible value' do
            expect(builds).to contain_exactly(
              a_hash_including(name: 'build1', interruptible: true),
              a_hash_including(name: 'build2', interruptible: false),
              a_hash_including(name: 'build3', interruptible: true),
              a_hash_including(name: 'bridge1', interruptible: true),
              a_hash_including(name: 'bridge2', interruptible: false),
              a_hash_including(name: 'bridge3', interruptible: true)
            )
          end
        end

        context 'when default:interruptible is false' do
          let(:default_config) do
            <<~YAML
              default:
                interruptible: false
            YAML
          end

          it 'returns jobs with their interruptible value' do
            expect(builds).to contain_exactly(
              a_hash_including(name: 'build1', interruptible: true),
              a_hash_including(name: 'build2', interruptible: false),
              a_hash_including(name: 'build3', interruptible: false),
              a_hash_including(name: 'bridge1', interruptible: true),
              a_hash_including(name: 'bridge2', interruptible: false),
              a_hash_including(name: 'bridge3', interruptible: false)
            )
          end
        end
      end
    end
  end
end