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

deployment_spec.rb « prerequisite « build « ci « gitlab « lib « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0c6175be1a25c68b94241724a59986d890c39e5d (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
# frozen_string_literal: true

require 'spec_helper'

describe Gitlab::Ci::Build::Prerequisite::Deployment do
  describe '#unmet?' do
    context 'when the build starts an environment' do
      it 'returns true if there is no deployment' do
        build = instance_double(Ci::Build, starts_environment?: true, has_deployment?: false)
        prerequisite = described_class.new(build)

        expect(prerequisite).to be_unmet
      end

      it 'returns false if there is a deployment' do
        build = instance_double(Ci::Build, starts_environment?: true, has_deployment?: true)
        prerequisite = described_class.new(build)

        expect(prerequisite).not_to be_unmet
      end
    end

    it 'returns false if the build does not start an environment' do
      build = instance_double(Ci::Build, starts_environment?: false)
      prerequisite = described_class.new(build)

      expect(prerequisite).not_to be_unmet
    end
  end

  describe '#complete!' do
    context 'when prerequisite is unmet' do
      it 'creates a deployment and environment' do
        build = instance_double(Ci::Build, starts_environment?: true, has_deployment?: false)
        prerequisite = described_class.new(build)

        expect(build).to receive(:create_deployment)

        prerequisite.complete!
      end
    end

    context 'when prerequisite is met' do
      it 'creates a deployment and environment' do
        build = instance_double(Ci::Build, starts_environment?: true, has_deployment?: true)
        prerequisite = described_class.new(build)

        expect(build).not_to receive(:create_deployment)

        prerequisite.complete!
      end
    end
  end
end