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
0e22b50d
Commit
0e22b50d
authored
May 30, 2018
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add spec for variables expression
parent
59e1e971
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
17 deletions
+53
-17
spec/lib/gitlab/ci/pipeline/chain/create_spec.rb
spec/lib/gitlab/ci/pipeline/chain/create_spec.rb
+15
-17
spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
+24
-0
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+14
-0
No files found.
spec/lib/gitlab/ci/pipeline/chain/create_spec.rb
View file @
0e22b50d
...
@@ -37,23 +37,21 @@ describe Gitlab::Ci::Pipeline::Chain::Create do
...
@@ -37,23 +37,21 @@ describe Gitlab::Ci::Pipeline::Chain::Create do
end
end
context
'when pipeline has validation errors'
do
context
'when pipeline has validation errors'
do
context
'when ref is nil'
do
let
(
:pipeline
)
do
let
(
:pipeline
)
do
build
(
:ci_pipeline
,
project:
project
,
ref:
nil
)
build
(
:ci_pipeline
,
project:
project
,
ref:
nil
)
end
end
before
do
before
do
step
.
perform!
step
.
perform!
end
end
it
'breaks the chain'
do
it
'breaks the chain'
do
expect
(
step
.
break?
).
to
be
true
expect
(
step
.
break?
).
to
be
true
end
end
it
'appends validation error'
do
it
'appends validation error'
do
expect
(
pipeline
.
errors
.
to_a
)
expect
(
pipeline
.
errors
.
to_a
)
.
to
include
/Failed to persist the pipeline/
.
to
include
/Failed to persist the pipeline/
end
end
end
end
end
end
end
spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
View file @
0e22b50d
...
@@ -42,6 +42,10 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
...
@@ -42,6 +42,10 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
it
'correctly assigns user'
do
it
'correctly assigns user'
do
expect
(
pipeline
.
builds
).
to
all
(
have_attributes
(
user:
user
))
expect
(
pipeline
.
builds
).
to
all
(
have_attributes
(
user:
user
))
end
end
it
'has pipeline iid'
do
expect
(
pipeline
.
iid
).
to
be
>
0
end
end
end
context
'when pipeline is empty'
do
context
'when pipeline is empty'
do
...
@@ -68,6 +72,10 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
...
@@ -68,6 +72,10 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
expect
(
pipeline
.
errors
.
to_a
)
expect
(
pipeline
.
errors
.
to_a
)
.
to
include
'No stages / jobs for this pipeline.'
.
to
include
'No stages / jobs for this pipeline.'
end
end
it
'wastes pipeline iid'
do
expect
(
InternalId
.
ci_pipelines
.
where
(
project_id:
project
.
id
).
last
.
last_value
).
to
be
>
0
end
end
end
context
'when pipeline has validation errors'
do
context
'when pipeline has validation errors'
do
...
@@ -87,6 +95,10 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
...
@@ -87,6 +95,10 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
expect
(
pipeline
.
errors
.
to_a
)
expect
(
pipeline
.
errors
.
to_a
)
.
to
include
'Failed to build the pipeline!'
.
to
include
'Failed to build the pipeline!'
end
end
it
'wastes pipeline iid'
do
expect
(
InternalId
.
ci_pipelines
.
where
(
project_id:
project
.
id
).
last
.
last_value
).
to
be
>
0
end
end
end
context
'when there is a seed blocks present'
do
context
'when there is a seed blocks present'
do
...
@@ -111,6 +123,12 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
...
@@ -111,6 +123,12 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
expect
(
pipeline
.
variables
.
first
.
key
).
to
eq
'VAR'
expect
(
pipeline
.
variables
.
first
.
key
).
to
eq
'VAR'
expect
(
pipeline
.
variables
.
first
.
value
).
to
eq
'123'
expect
(
pipeline
.
variables
.
first
.
value
).
to
eq
'123'
end
end
it
'has pipeline iid'
do
step
.
perform!
expect
(
pipeline
.
iid
).
to
be
>
0
end
end
end
context
'when seeds block tries to persist some resources'
do
context
'when seeds block tries to persist some resources'
do
...
@@ -121,6 +139,12 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
...
@@ -121,6 +139,12 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
it
'raises exception'
do
it
'raises exception'
do
expect
{
step
.
perform!
}.
to
raise_error
(
ActiveRecord
::
RecordNotSaved
)
expect
{
step
.
perform!
}.
to
raise_error
(
ActiveRecord
::
RecordNotSaved
)
end
end
it
'does not waste pipeline iid'
do
step
.
perform
rescue
nil
expect
(
InternalId
.
ci_pipelines
.
where
(
project_id:
project
.
id
).
exists?
).
to
be_falsy
end
end
end
end
end
...
...
spec/models/ci/pipeline_spec.rb
View file @
0e22b50d
...
@@ -397,6 +397,20 @@ describe Ci::Pipeline, :mailer do
...
@@ -397,6 +397,20 @@ describe Ci::Pipeline, :mailer do
expect
(
seeds
.
size
).
to
eq
1
expect
(
seeds
.
size
).
to
eq
1
expect
(
seeds
.
dig
(
0
,
0
,
:name
)).
to
eq
'unit'
expect
(
seeds
.
dig
(
0
,
0
,
:name
)).
to
eq
'unit'
end
end
context
"when pipeline iid is used for 'only' keyword"
do
let
(
:config
)
do
{
rspec:
{
script:
'rspec'
,
only:
{
variables:
[
'$CI_PIPELINE_IID == 2'
]
}
},
prod:
{
script:
'cap prod'
,
only:
{
variables:
[
'$CI_PIPELINE_IID == 1'
]
}
}
}
end
it
'returns stage seeds only when variables expression is truthy'
do
seeds
=
pipeline
.
stage_seeds
expect
(
seeds
.
size
).
to
eq
1
expect
(
seeds
.
dig
(
0
,
0
,
:name
)).
to
eq
'prod'
end
end
end
end
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