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
end
end
describe '#codeclimate_artifact' do
context 'has codequality job' do
let!(:build) do
create(
:ci_build,
:artifacts,
name: 'codequality',
pipeline: pipeline,
options: {
artifacts: {
paths: ['codeclimate.json']
ARTIFACTS_METHODS = {
codeclimate_artifact: Ci::Build::CODEQUALITY_FILE,
performance_artifact: Ci::Build::PERFORMANCE_FILE,
sast_artifact: Ci::Build::SAST_FILE,
clair_artifact: Ci::Build::CLAIR_FILE
}.freeze
ARTIFACTS_METHODS.each do |method, filename|
describe "##{method}codeclimate_artifact" do
context 'has corresponding job' do
let!(:build) do
create(
:ci_build,
:artifacts,
name: method.to_s.sub('_artifact', ''),
pipeline: pipeline,
options: {
artifacts: {
paths: [filename]
}
}
}
)
end
it { expect(pipeline.codeclimate_artifact).to eq(build) }
end
)
end
context 'no codequality job' do
before do
create(:ci_build, pipeline: pipeline)
it { expect(pipeline.send(method)).to eq(build) }
end
it { expect(pipeline.codeclimate_artifact).to be_nil }
end
end
context 'no codequality job' do
before do
create(:ci_build, pipeline: pipeline)
end
describe '#performance_artifact' do
context 'has performance job' do
let!(:build) do
create(
:ci_build,
:artifacts,
name: 'performance',
pipeline: pipeline,
options: {
artifacts: {
paths: ['performance.json']
}
}
)
it { expect(pipeline.send(method)).to be_nil }
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
......@@ -246,4 +246,8 @@ describe MergeRequest do
it { expect(merge_request.has_sast_data?).to be_truthy }
end
describe '#clair_artifact' do
it { is_expected.to delegate_method(:clair_artifact).to(:head_pipeline) }
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