Коммит 3638e7a6 создал по автору Sam White's avatar Sam White
Просмотр файлов

Use let_it_be in DS Tests

владелец 9f3da4bc
......@@ -29,10 +29,10 @@
end
with_them do
let(:project) { create(:project, :custom_repo, files: files_at_depth_x) }
let_it_be(:project) { create(:project, :custom_repo, files: files_at_depth_x) }
context 'with file at root' do
let(:files_at_depth_x) { files }
let_it_be(:files_at_depth_x) { files }
it 'creates a pipeline with the expected jobs' do
expect(build_names).to include(*include_build_names)
......@@ -43,7 +43,7 @@
context 'with file at depth 1' do
# prepend a directory to files (e.g. convert go.sum to foo/go.sum)
let(:files_at_depth_x) { files.transform_keys { |k| "foo/#{k}" } }
let_it_be(:files_at_depth_x) { files.transform_keys { |k| "foo/#{k}" } }
it 'creates a pipeline with the expected jobs' do
expect(build_names).to include(*include_build_names)
......@@ -54,7 +54,7 @@
context 'with file at depth 2' do
# prepend a directory to files (e.g. convert go.sum to foo/bar/go.sum)
let(:files_at_depth_x) { files.transform_keys { |k| "foo/bar/#{k}" } }
let_it_be(:files_at_depth_x) { files.transform_keys { |k| "foo/bar/#{k}" } }
it 'creates a pipeline with the expected jobs' do
expect(build_names).to include(*include_build_names)
......@@ -64,7 +64,7 @@
end
context 'with file at depth > 2' do
let(:files_at_depth_x) { files.transform_keys { |k| "foo/bar/baz/#{k}" } }
let_it_be(:files_at_depth_x) { files.transform_keys { |k| "foo/bar/baz/#{k}" } }
it 'includes no job' do
expect(build_names).to be_empty
......@@ -100,7 +100,7 @@
RSpec.shared_examples 'DS_REMEDIATE default value' do |expected|
context 'project supported by gemnasium analyzer' do
let(:project) { create(:project, :custom_repo, files: { 'yarn.lock' => '' }) }
let_it_be(:project) { create(:project, :custom_repo, files: { 'yarn.lock' => '' }) }
it 'sets default value for DS_REMEDIATE' do
build = pipeline.builds.first
......@@ -113,13 +113,13 @@
subject(:template) { Gitlab::Template::GitlabCiYmlTemplate.find('Dependency-Scanning') }
describe 'the created pipeline' do
let(:default_branch) { 'master' }
let(:files) { { 'README.txt' => '' } }
let(:project) { create(:project, :custom_repo, files: files) }
let(:user) { project.first_owner }
let(:service) { Ci::CreatePipelineService.new(project, user, ref: 'master') }
let(:pipeline) { service.execute(:push).payload }
let(:build_names) { pipeline.builds.pluck(:name) }
let_it_be(:default_branch) { 'master' }
let_it_be(:files) { { 'README.txt' => '' } }
let_it_be(:project) { create(:project, :custom_repo, files: files) }
let_it_be(:user) { project.first_owner }
let_it_be(:service) { Ci::CreatePipelineService.new(project, user, ref: 'master') }
let_it_be(:pipeline) { service.execute(:push).payload }
let_it_be(:build_names) { pipeline.builds.pluck(:name) }
before do
stub_ci_pipeline_yaml_file(template.content)
......@@ -138,7 +138,7 @@
end
context 'when project has Ultimate license' do
let(:license) { build(:license, plan: License::ULTIMATE_PLAN) }
let_it_be(:license) { build(:license, plan: License::ULTIMATE_PLAN) }
before do
allow(License).to receive(:current).and_return(license)
......@@ -157,7 +157,7 @@
end
context 'when DS_EXCLUDED_ANALYZERS set to' do
let(:files) { { 'conan.lock' => '', 'Gemfile.lock' => '', 'package.json' => '', 'pom.xml' => '', 'Pipfile' => '' } }
let_it_be(:files) { { 'conan.lock' => '', 'Gemfile.lock' => '', 'package.json' => '', 'pom.xml' => '', 'Pipfile' => '' } }
describe 'exclude' do
using RSpec::Parameterized::TableSyntax
......@@ -197,7 +197,7 @@
end
context 'by default', fips_mode: false do
let(:expected_image_suffix) { "" }
let_it_be(:expected_image_suffix) { "" }
include_examples 'language detection'
include_examples 'PIP_REQUIREMENTS_FILE support'
......@@ -205,7 +205,7 @@
end
context 'when FIPS mode is enabled', :fips_mode do
let(:expected_image_suffix) { "-fips" }
let_it_be(:expected_image_suffix) { "-fips" }
include_examples 'language detection'
include_examples 'PIP_REQUIREMENTS_FILE support'
......
......@@ -30,10 +30,10 @@
end
with_them do
let(:project) { create(:project, :custom_repo, files: files_at_depth_x) }
let_it_be(:project) { create(:project, :custom_repo, files: files_at_depth_x) }
context 'with file at root' do
let(:files_at_depth_x) { files }
let_it_be(:files_at_depth_x) { files }
it 'creates a pipeline with the expected jobs' do
expect(build_names).to include(*include_build_names)
......@@ -44,7 +44,7 @@
context 'with file at depth 1' do
# prepend a directory to files (e.g. convert go.sum to foo/go.sum)
let(:files_at_depth_x) { files.transform_keys { |k| "foo/#{k}" } }
let_it_be(:files_at_depth_x) { files.transform_keys { |k| "foo/#{k}" } }
it 'creates a pipeline with the expected jobs' do
expect(build_names).to include(*include_build_names)
......@@ -55,7 +55,7 @@
context 'with file at depth 2' do
# prepend a directory to files (e.g. convert go.sum to foo/bar/go.sum)
let(:files_at_depth_x) { files.transform_keys { |k| "foo/bar/#{k}" } }
let_it_be(:files_at_depth_x) { files.transform_keys { |k| "foo/bar/#{k}" } }
it 'creates a pipeline with the expected jobs' do
expect(build_names).to include(*include_build_names)
......@@ -65,7 +65,7 @@
end
context 'with file at depth > 2' do
let(:files_at_depth_x) { files.transform_keys { |k| "foo/bar/baz/#{k}" } }
let_it_be(:files_at_depth_x) { files.transform_keys { |k| "foo/bar/baz/#{k}" } }
it 'includes no job' do
expect(build_names).to be_empty
......@@ -75,12 +75,12 @@
end
context 'with merge request pipelines' do
let(:service) { MergeRequests::CreatePipelineService.new(project: project, current_user: user) }
let(:feature_branch) { 'feature' }
let(:pipeline) { service.execute(merge_request).payload }
let(:files_at_depth_x) { files }
let_it_be(:service) { MergeRequests::CreatePipelineService.new(project: project, current_user: user) }
let_it_be(:feature_branch) { 'feature' }
let_it_be(:pipeline) { service.execute(merge_request).payload }
let_it_be(:files_at_depth_x) { files }
let(:merge_request) do
let_it_be(:merge_request) do
create(:merge_request,
source_project: project,
source_branch: feature_branch,
......@@ -133,7 +133,7 @@
RSpec.shared_examples 'DS_REMEDIATE default value' do |expected|
context 'when project supported by gemnasium analyzer' do
let(:project) { create(:project, :custom_repo, files: { 'yarn.lock' => '' }) }
let_it_be(:project) { create(:project, :custom_repo, files: { 'yarn.lock' => '' }) }
it 'sets default value for DS_REMEDIATE' do
build = pipeline.builds.first
......@@ -151,13 +151,13 @@
end
context 'on branch pipeline' do
let(:default_branch) { 'master' }
let(:files) { { 'README.txt' => '' } }
let(:project) { create(:project, :custom_repo, files: files) }
let(:user) { project.first_owner }
let(:service) { Ci::CreatePipelineService.new(project, user, ref: 'master') }
let(:pipeline) { service.execute(:push).payload }
let(:build_names) { pipeline.builds.pluck(:name) }
let_it_be(:default_branch) { 'master' }
let_it_be(:files) { { 'README.txt' => '' } }
let_it_be(:project) { create(:project, :custom_repo, files: files) }
let_it_be(:user) { project.first_owner }
let_it_be(:service) { Ci::CreatePipelineService.new(project, user, ref: 'master') }
let_it_be(:pipeline) { service.execute(:push).payload }
let_it_be(:build_names) { pipeline.builds.pluck(:name) }
before do
stub_ci_pipeline_yaml_file(template)
......@@ -176,7 +176,7 @@
end
context 'when project has Ultimate license' do
let(:license) { build(:license, plan: License::ULTIMATE_PLAN) }
let_it_be(:license) { build(:license, plan: License::ULTIMATE_PLAN) }
before do
allow(License).to receive(:current).and_return(license)
......@@ -195,7 +195,7 @@
end
context 'when DS_EXCLUDED_ANALYZERS set to' do
let(:files) { { 'conan.lock' => '', 'Gemfile.lock' => '', 'package.json' => '', 'pom.xml' => '', 'Pipfile' => '' } }
let_it_be(:files) { { 'conan.lock' => '', 'Gemfile.lock' => '', 'package.json' => '', 'pom.xml' => '', 'Pipfile' => '' } }
describe 'exclude' do
using RSpec::Parameterized::TableSyntax
......@@ -235,7 +235,7 @@
end
context 'as default', fips_mode: false do
let(:expected_image_suffix) { "" }
let_it_be(:expected_image_suffix) { "" }
include_examples 'language detection'
include_examples 'PIP_REQUIREMENTS_FILE support'
......@@ -243,7 +243,7 @@
end
context 'when FIPS mode is enabled', :fips_mode do
let(:expected_image_suffix) { "-fips" }
let_it_be(:expected_image_suffix) { "-fips" }
include_examples 'language detection'
include_examples 'PIP_REQUIREMENTS_FILE support'
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать