Открыть боковую панель
GitLab.org
Gitlab
Коммиты
3638e7a6
Коммит
3638e7a6
создал
Фев 17, 2023
по автору
Sam White
Просмотр файлов
Use let_it_be in DS Tests
владелец
9f3da4bc
Изменения
2
Скрыть пробелы
Построчно
Рядом
ee/spec/lib/gitlab/ci/templates/dependency_scanning_gitlab_ci_yaml_spec.rb
Просмотр файла @
3638e7a6
...
...
@@ -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'
...
...
ee/spec/lib/gitlab/ci/templates/dependency_scanning_latest_gitlab_ci_yaml_spec.rb
Просмотр файла @
3638e7a6
...
...
@@ -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.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать