Refactor Normalizer specs
This commit is contained in:
parent
4b2b154c4e
commit
f48261a409
2 changed files with 3 additions and 11 deletions
|
@ -27,7 +27,7 @@ module Gitlab
|
||||||
|
|
||||||
def parallelize_jobs(jobs_config, parallelized_jobs)
|
def parallelize_jobs(jobs_config, parallelized_jobs)
|
||||||
jobs_config.each_with_object({}) do |(job_name, config), hash|
|
jobs_config.each_with_object({}) do |(job_name, config), hash|
|
||||||
if parallelized_jobs.keys.include?(job_name)
|
if parallelized_jobs.key?(job_name)
|
||||||
parallelized_jobs[job_name].each { |name, index| hash[name.to_sym] = config.merge(name: name, instance: index) }
|
parallelized_jobs[job_name].each { |name, index| hash[name.to_sym] = config.merge(name: name, instance: index) }
|
||||||
else
|
else
|
||||||
hash[job_name] = config
|
hash[job_name] = config
|
||||||
|
|
|
@ -15,7 +15,7 @@ describe Gitlab::Ci::Config::Normalizer do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has parallelized jobs' do
|
it 'has parallelized jobs' do
|
||||||
job_names = described_class.send(:parallelize_job_names, job_name, 5).map { |job_name, index| job_name.to_sym }
|
job_names = [:"rspec 1/5", :"rspec 2/5", :"rspec 3/5", :"rspec 4/5", :"rspec 5/5"]
|
||||||
|
|
||||||
is_expected.to include(*job_names)
|
is_expected.to include(*job_names)
|
||||||
end
|
end
|
||||||
|
@ -35,18 +35,10 @@ describe Gitlab::Ci::Config::Normalizer do
|
||||||
let(:config) { { job_name => job_config, other_job: { script: 'echo 1', dependencies: [job_name.to_s] } } }
|
let(:config) { { job_name => job_config, other_job: { script: 'echo 1', dependencies: [job_name.to_s] } } }
|
||||||
|
|
||||||
it 'parallelizes dependencies' do
|
it 'parallelizes dependencies' do
|
||||||
job_names = described_class.send(:parallelize_job_names, job_name, 5).map(&:first)
|
job_names = ["rspec 1/5", "rspec 2/5", "rspec 3/5", "rspec 4/5", "rspec 5/5"]
|
||||||
|
|
||||||
expect(subject[:other_job][:dependencies]).to include(*job_names)
|
expect(subject[:other_job][:dependencies]).to include(*job_names)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.parallelize_job_names' do
|
|
||||||
subject { described_class.send(:parallelize_job_names, job_name, 5) }
|
|
||||||
|
|
||||||
it 'returns parallelized names' do
|
|
||||||
expect(subject.map(&:first)).to all(match(%r{#{job_name} \d+/\d+}))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue