diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-18 14:14:39 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-18 14:14:39 +0000 |
commit | 1eb82b65c554f21d83447f895a6208905fabe112 (patch) | |
tree | ab12f01b3dc46f11c02afea1e470a78f06ca70c2 /spec/models/ci | |
parent | 4ab54c2233e91f60a80e5b6fa2181e6899fdcc3e (diff) | |
download | gitlab-ce-stable-branch-foss-test.tar.gz |
Add latest changes from gitlab-org/gitlab@12-3-auto-deploy-20190916stable-branch-foss-test
Diffstat (limited to 'spec/models/ci')
-rw-r--r-- | spec/models/ci/build_metadata_spec.rb | 70 |
1 files changed, 20 insertions, 50 deletions
diff --git a/spec/models/ci/build_metadata_spec.rb b/spec/models/ci/build_metadata_spec.rb index 67cd939b4c6..917a65ddf21 100644 --- a/spec/models/ci/build_metadata_spec.rb +++ b/spec/models/ci/build_metadata_spec.rb @@ -22,72 +22,42 @@ describe Ci::BuildMetadata do describe '#update_timeout_state' do subject { metadata } - shared_examples 'sets timeout' do |source, timeout| - it 'sets project_timeout_source' do - expect { subject.update_timeout_state }.to change { subject.reload.timeout_source }.to(source) + context 'when runner is not assigned to the job' do + it "doesn't change timeout value" do + expect { subject.update_timeout_state }.not_to change { subject.reload.timeout } end - it 'sets project timeout' do - expect { subject.update_timeout_state }.to change { subject.reload.timeout }.to(timeout) + it "doesn't change timeout_source value" do + expect { subject.update_timeout_state }.not_to change { subject.reload.timeout_source } end end - context 'when project timeout is set' do - context 'when runner is assigned to the job' do - before do - build.update!(runner: runner) - end - - context 'when runner timeout is not set' do - let(:runner) { create(:ci_runner, maximum_timeout: nil) } - - it_behaves_like 'sets timeout', 'project_timeout_source', 2000 - end - - context 'when runner timeout is lower than project timeout' do - let(:runner) { create(:ci_runner, maximum_timeout: 1900) } - - it_behaves_like 'sets timeout', 'runner_timeout_source', 1900 - end - - context 'when runner timeout is higher than project timeout' do - let(:runner) { create(:ci_runner, maximum_timeout: 2100) } - - it_behaves_like 'sets timeout', 'project_timeout_source', 2000 - end + context 'when runner is assigned to the job' do + before do + build.update(runner: runner) end - context 'when job timeout is set' do - context 'when job timeout is higher than project timeout' do - let(:build) { create(:ci_build, pipeline: pipeline, options: { job_timeout: 3000 }) } + context 'when runner timeout is lower than project timeout' do + let(:runner) { create(:ci_runner, maximum_timeout: 1900) } - it_behaves_like 'sets timeout', 'job_timeout_source', 3000 + it 'sets runner timeout' do + expect { subject.update_timeout_state }.to change { subject.reload.timeout }.to(1900) end - context 'when job timeout is lower than project timeout' do - let(:build) { create(:ci_build, pipeline: pipeline, options: { job_timeout: 1000 }) } - - it_behaves_like 'sets timeout', 'job_timeout_source', 1000 + it 'sets runner_timeout_source' do + expect { subject.update_timeout_state }.to change { subject.reload.timeout_source }.to('runner_timeout_source') end end - context 'when both runner and job timeouts are set' do - before do - build.update(runner: runner) - end - - context 'when job timeout is higher than runner timeout' do - let(:build) { create(:ci_build, pipeline: pipeline, options: { job_timeout: 3000 }) } - let(:runner) { create(:ci_runner, maximum_timeout: 2100) } + context 'when runner timeout is higher than project timeout' do + let(:runner) { create(:ci_runner, maximum_timeout: 2100) } - it_behaves_like 'sets timeout', 'runner_timeout_source', 2100 + it 'sets project timeout' do + expect { subject.update_timeout_state }.to change { subject.reload.timeout }.to(2000) end - context 'when job timeout is lower than runner timeout' do - let(:build) { create(:ci_build, pipeline: pipeline, options: { job_timeout: 1900 }) } - let(:runner) { create(:ci_runner, maximum_timeout: 2100) } - - it_behaves_like 'sets timeout', 'job_timeout_source', 1900 + it 'sets project_timeout_source' do + expect { subject.update_timeout_state }.to change { subject.reload.timeout_source }.to('project_timeout_source') end end end |