Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
0c752d0a
Commit
0c752d0a
authored
Mar 31, 2021
by
Marius Bobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor specs to improve clarity
parent
bd893a26
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
13 deletions
+20
-13
ee/spec/services/ci/create_pipeline_service/needs_spec.rb
ee/spec/services/ci/create_pipeline_service/needs_spec.rb
+19
-11
ee/spec/services/ci/create_pipeline_service_spec.rb
ee/spec/services/ci/create_pipeline_service_spec.rb
+1
-2
No files found.
ee/spec/services/ci/create_pipeline_service/needs_spec.rb
View file @
0c752d0a
...
...
@@ -3,8 +3,6 @@
require
'spec_helper'
RSpec
.
describe
Ci
::
CreatePipelineService
do
subject
(
:execute
)
{
service
.
execute
(
:push
)
}
let_it_be
(
:downstream_project
)
{
create
(
:project
,
name:
'project'
,
namespace:
create
(
:namespace
,
name:
'some'
))
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
project
.
owner
}
...
...
@@ -30,29 +28,34 @@ RSpec.describe Ci::CreatePipelineService do
end
it
'persists pipeline'
do
expect
(
execute
).
to
be_persisted
pipeline
=
create_pipeline!
expect
(
pipeline
).
to
be_persisted
end
it
'persists both jobs'
do
expect
{
execute
}.
to
change
(
Ci
::
Build
,
:count
).
from
(
0
).
to
(
1
)
expect
{
create_pipeline!
}.
to
change
(
Ci
::
Build
,
:count
).
from
(
0
).
to
(
1
)
.
and
change
(
Ci
::
Bridge
,
:count
).
from
(
0
).
to
(
1
)
end
it
'persists bridge needs'
do
job
=
execute
.
builds
.
first
bridge
=
execute
.
stages
.
last
.
bridges
.
first
pipeline
=
create_pipeline!
job
=
pipeline
.
builds
.
first
bridge
=
pipeline
.
bridges
.
first
expect
(
bridge
.
needs
.
first
.
name
).
to
eq
(
job
.
name
)
end
it
'persists bridge target project'
do
bridge
=
execute
.
stages
.
last
.
bridges
.
first
pipeline
=
create_pipeline!
bridge
=
pipeline
.
bridges
.
first
expect
(
bridge
.
downstream_project
).
to
eq
downstream_project
end
it
"sets scheduling_type of bridge_dag_job as 'dag'"
do
bridge
=
execute
.
stages
.
last
.
bridges
.
first
pipeline
=
create_pipeline!
bridge
=
pipeline
.
bridges
.
first
expect
(
bridge
.
scheduling_type
).
to
eq
(
'dag'
)
end
...
...
@@ -71,14 +74,14 @@ RSpec.describe Ci::CreatePipelineService do
end
it
'creates a pipeline with regular_job and bridge_dag_job pending'
do
pipeline
=
execute
pipeline
=
create_pipeline!
processables
=
pipeline
.
processables
Ci
::
InitialPipelineProcessWorker
.
new
.
perform
(
pipeline
.
id
)
regular_job
=
processables
.
find
{
|
processable
|
processable
.
name
==
'regular_job'
}
bridge_dag_job
=
processables
.
find
{
|
processable
|
processable
.
name
==
'bridge_dag_job'
}
expect
(
execut
e
).
to
be_persisted
expect
(
pipelin
e
).
to
be_persisted
expect
(
regular_job
.
status
).
to
eq
(
'pending'
)
expect
(
bridge_dag_job
.
status
).
to
eq
(
'pending'
)
end
...
...
@@ -112,11 +115,16 @@ RSpec.describe Ci::CreatePipelineService do
end
it
'has dependencies and variables'
,
:aggregate_failures
do
job
=
execute
.
builds
.
first
pipeline
=
create_pipeline!
job
=
pipeline
.
builds
.
first
expect
(
job
).
to
be_present
expect
(
job
.
all_dependencies
).
to
include
(
dependency
)
expect
(
job
.
scoped_variables
.
to_hash
).
to
include
(
dependency_variable
.
key
=>
dependency_variable
.
value
)
end
end
def
create_pipeline!
service
.
execute
(
:push
)
end
end
ee/spec/services/ci/create_pipeline_service_spec.rb
View file @
0c752d0a
...
...
@@ -31,8 +31,7 @@ RSpec.describe Ci::CreatePipelineService, '#execute' do
it
'enqueues a new pipeline'
do
pipeline
=
create_pipeline!
expect
(
pipeline
).
to
be_persisted
expect
(
pipeline
).
to
be_created
expect
(
pipeline
).
to
be_created_successfully
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment