Commit 24d4e462 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add specs to clair related code in pipeline and mr

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent a2ab79f9
...@@ -15,87 +15,40 @@ describe Ci::Pipeline do ...@@ -15,87 +15,40 @@ describe Ci::Pipeline do
end end
end end
describe '#codeclimate_artifact' do ARTIFACTS_METHODS = {
context 'has codequality job' do codeclimate_artifact: Ci::Build::CODEQUALITY_FILE,
let!(:build) do performance_artifact: Ci::Build::PERFORMANCE_FILE,
create( sast_artifact: Ci::Build::SAST_FILE,
:ci_build, clair_artifact: Ci::Build::CLAIR_FILE
:artifacts, }.freeze
name: 'codequality',
pipeline: pipeline, ARTIFACTS_METHODS.each do |method, filename|
options: { describe "##{method}codeclimate_artifact" do
artifacts: { context 'has corresponding job' do
paths: ['codeclimate.json'] let!(:build) do
create(
:ci_build,
:artifacts,
name: method.to_s.sub('_artifact', ''),
pipeline: pipeline,
options: {
artifacts: {
paths: [filename]
}
} }
} )
) end
end
it { expect(pipeline.codeclimate_artifact).to eq(build) }
end
context 'no codequality job' do it { expect(pipeline.send(method)).to eq(build) }
before do
create(:ci_build, pipeline: pipeline)
end end
it { expect(pipeline.codeclimate_artifact).to be_nil } context 'no codequality job' do
end before do
end create(:ci_build, pipeline: pipeline)
end
describe '#performance_artifact' do it { expect(pipeline.send(method)).to be_nil }
context 'has performance job' do
let!(:build) do
create(
:ci_build,
:artifacts,
name: 'performance',
pipeline: pipeline,
options: {
artifacts: {
paths: ['performance.json']
}
}
)
end end
it { expect(pipeline.performance_artifact).to eq(build) }
end
context 'no performance job' do
before do
create(:ci_build, pipeline: pipeline)
end
it { expect(pipeline.performance_artifact).to be_nil }
end
end
describe '#sast_artifact' do
context 'has sast job' do
let!(:build) do
create(
:ci_build,
:artifacts,
name: 'sast',
pipeline: pipeline,
options: {
artifacts: {
paths: ['gl-sast-report.json']
}
}
)
end
it { expect(pipeline.sast_artifact).to eq(build) }
end
context 'no sast job' do
before do
create(:ci_build, pipeline: pipeline)
end
it { expect(pipeline.sast_artifact).to be_nil }
end end
end end
end end
...@@ -246,4 +246,8 @@ describe MergeRequest do ...@@ -246,4 +246,8 @@ describe MergeRequest do
it { expect(merge_request.has_sast_data?).to be_truthy } it { expect(merge_request.has_sast_data?).to be_truthy }
end end
describe '#clair_artifact' do
it { is_expected.to delegate_method(:clair_artifact).to(:head_pipeline) }
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment