diff options
author | Shinya Maeda <shinya@gitlab.com> | 2017-09-07 12:36:34 +0300 |
---|---|---|
committer | Shinya Maeda <shinya@gitlab.com> | 2017-09-07 12:36:34 +0300 |
commit | f946558bb3b4ba6ff67a8c306af249b8d5350f39 (patch) | |
tree | 91507865751b6c001a94e92f74b5941a87ccc384 /spec | |
parent | ac955b7d61d0d2b9ba351efacc20e4a666760109 (diff) |
IMplement InternalId2
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/ci/build_spec.rb | 1 | ||||
-rw-r--r-- | spec/models/ci/pipeline_spec.rb | 29 | ||||
-rw-r--r-- | spec/services/ci/create_pipeline_service_spec.rb | 1 |
3 files changed, 30 insertions, 1 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 08d22f166e4..b9c97253d35 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1260,6 +1260,7 @@ describe Ci::Build do { key: 'CI_PROJECT_NAMESPACE', value: project.namespace.full_path, public: true }, { key: 'CI_PROJECT_URL', value: project.web_url, public: true }, { key: 'CI_PIPELINE_ID', value: pipeline.id.to_s, public: true }, + { key: 'CI_PIPELINE_IID', value: pipeline.iid.to_s, public: true }, { key: 'CI_CONFIG_PATH', value: pipeline.ci_yaml_file_path, public: true }, { key: 'CI_REGISTRY_USER', value: 'gitlab-ci-token', public: true }, { key: 'CI_REGISTRY_PASSWORD', value: build.token, public: false }, diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 84656ffe0b9..8616d44fe44 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -27,6 +27,22 @@ describe Ci::Pipeline, :mailer do it { is_expected.to respond_to :git_author_email } it { is_expected.to respond_to :short_sha } + describe 'IID' do + it 'creates sequential iid in the same project' do + p1 = create(:ci_empty_pipeline, project: project) + p2 = create(:ci_empty_pipeline, project: project) + expect(p1.iid).to eq(0) + expect(p2.iid).to eq(1) + end + + it 'creates the same iid in the different project' do + p1 = create(:ci_empty_pipeline, project: project) + p2 = create(:ci_empty_pipeline, project: create(:project)) + expect(p1.iid).to eq(0) + expect(p2.iid).to eq(0) + end + end + describe '#source' do context 'when creating new pipeline' do let(:pipeline) do @@ -167,7 +183,18 @@ describe Ci::Pipeline, :mailer do it 'includes the defined keys' do keys = subject.map { |v| v[:key] } - expect(keys).to include('CI_PIPELINE_ID', 'CI_CONFIG_PATH', 'CI_PIPELINE_SOURCE') + expect(keys).to eq(['CI_PIPELINE_ID', 'CI_PIPELINE_IID', 'CI_CONFIG_PATH', 'CI_PIPELINE_SOURCE']) + end + + context 'when iid is nil' do + before do + pipeline.update_columns(iid: nil) + end + + it 'returns empty iid' do + value = subject.select { |s| s[:key] == 'CI_PIPELINE_IID' } .first[:value] + expect(value).to be_empty + end end end diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb index 49d7c663128..c74d2d1da84 100644 --- a/spec/services/ci/create_pipeline_service_spec.rb +++ b/spec/services/ci/create_pipeline_service_spec.rb @@ -43,6 +43,7 @@ describe Ci::CreatePipelineService do expect(pipeline).to have_attributes(user: user) expect(pipeline).to have_attributes(status: 'pending') expect(pipeline.builds.first).to be_kind_of(Ci::Build) + expect(pipeline.iid).to eq(0) end it 'increments the prometheus counter' do |