Commit e13ac1be authored by Mehmet Emin INAC's avatar Mehmet Emin INAC

Extend the test cases with more scenarios

parent d6e2cf27
...@@ -916,8 +916,9 @@ RSpec.describe MergeRequest do ...@@ -916,8 +916,9 @@ RSpec.describe MergeRequest do
end end
context 'when there is a head pipeline' do context 'when there is a head pipeline' do
let_it_be(:head_pipeline) { create(:ee_ci_pipeline, project: project, sha: merge_request.diff_head_sha) }
before do before do
create(:ee_ci_pipeline, project: project, sha: merge_request.diff_head_sha)
merge_request.update_head_pipeline merge_request.update_head_pipeline
end end
...@@ -933,20 +934,50 @@ RSpec.describe MergeRequest do ...@@ -933,20 +934,50 @@ RSpec.describe MergeRequest do
sha: merge_request.diff_base_sha) sha: merge_request.diff_base_sha)
end end
context 'when there are missing security scans for the head pipeline' do let_it_be(:base_pipeline_build) { create(:ci_build, :success, pipeline: base_pipeline, project: project) }
let(:missing_scan_type) { 'sast' } let_it_be(:head_pipeline_build) { create(:ci_build, :success, pipeline: head_pipeline, project: project) }
context 'when the head pipeline does not have security scans' do
context 'when the base pipeline does not have security scans' do
it { is_expected.to be_empty }
end
context 'when the base pipeline has security scans' do
before do before do
build = create(:ci_build, :success, pipeline: base_pipeline, project: project) create(:security_scan, build: base_pipeline_build, scan_type: 'sast')
create(:security_scan, build: build, scan_type: missing_scan_type) end
it { is_expected.to eq(['sast']) }
end
end
context 'when the head pipeline has security scans' do
before do
create(:security_scan, build: head_pipeline_build, scan_type: 'dast')
end end
it { is_expected.to eq([missing_scan_type]) } context 'when the base pipeline does not have security scans' do
it { is_expected.to be_empty }
end
context 'when the base pipeline has security scans' do
before do
create(:security_scan, build: base_pipeline_build, scan_type: 'dast')
end end
context 'when there is no missing security scan for the head pipeline' do context 'when there are no missing security scans for the head pipeline' do
it { is_expected.to be_empty } it { is_expected.to be_empty }
end end
context 'when there are missing security scans for the head pipeline' do
before do
create(:security_scan, build: base_pipeline_build, scan_type: 'sast')
end
it { is_expected.to eq(['sast']) }
end
end
end
end end
end 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