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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
6a9cfdde
Commit
6a9cfdde
authored
Sep 26, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for pipeline builder that validates config
parent
39f05fd8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
127 additions
and
0 deletions
+127
-0
spec/lib/gitlab/ci/pipeline/chain/validate/config_spec.rb
spec/lib/gitlab/ci/pipeline/chain/validate/config_spec.rb
+127
-0
No files found.
spec/lib/gitlab/ci/pipeline/chain/validate/config_spec.rb
0 → 100644
View file @
6a9cfdde
require
'spec_helper'
describe
Gitlab
::
Ci
::
Pipeline
::
Chain
::
Validate
::
Config
do
set
(
:project
)
{
create
(
:project
)
}
set
(
:user
)
{
create
(
:user
)
}
let
(
:command
)
do
double
(
'command'
,
project:
project
,
current_user:
user
,
save_incompleted:
true
)
end
let!
(
:step
)
{
described_class
.
new
(
pipeline
,
command
)
}
before
do
step
.
perform!
end
context
'when pipeline has no YAML configuration'
do
let
(
:pipeline
)
do
build_stubbed
(
:ci_pipeline
,
project:
project
)
end
it
'appends errors about missing configuration'
do
expect
(
pipeline
.
errors
.
to_a
)
.
to
include
'Missing .gitlab-ci.yml file'
end
it
'breaks the chain'
do
expect
(
step
.
break?
).
to
be
true
end
end
context
'when YAML configuration contains errors'
do
let
(
:pipeline
)
do
build
(
:ci_pipeline
,
project:
project
,
config:
'invalid YAML'
)
end
it
'appends errors about YAML errors'
do
expect
(
pipeline
.
errors
.
to_a
)
.
to
include
'Invalid configuration format'
end
it
'breaks the chain'
do
expect
(
step
.
break?
).
to
be
true
end
context
'when saving incomplete pipeline is allowed'
do
let
(
:command
)
do
double
(
'command'
,
project:
project
,
current_user:
user
,
save_incompleted:
true
)
end
it
'fails the pipeline'
do
expect
(
pipeline
.
reload
).
to
be_failed
end
end
context
'when saving incomplete pipeline is not allowed'
do
let
(
:command
)
do
double
(
'command'
,
project:
project
,
current_user:
user
,
save_incompleted:
false
)
end
it
'does not drop pipeline'
do
expect
(
pipeline
).
not_to
be_failed
expect
(
pipeline
).
not_to
be_persisted
end
end
end
context
'when pipeline has no stages / jobs'
do
let
(
:config
)
do
{
rspec:
{
script:
'ls'
,
only:
[
'something'
]
}
}
end
let
(
:pipeline
)
do
build
(
:ci_pipeline
,
project:
project
,
config:
config
)
end
it
'appends an error about missing stages'
do
expect
(
pipeline
.
errors
.
to_a
)
.
to
include
'No stages / jobs for this pipeline.'
end
it
'breaks the chain'
do
expect
(
step
.
break?
).
to
be
true
end
end
context
'when pipeline contains configuration validation errors'
do
let
(
:config
)
{
{
rspec:
{
}
}
}
let
(
:pipeline
)
do
build
(
:ci_pipeline
,
project:
project
,
config:
config
)
end
it
'appends configuration validation errors to pipeline errors'
do
expect
(
pipeline
.
errors
.
to_a
)
.
to
include
"jobs:rspec config can't be blank"
end
it
'breaks the chain'
do
expect
(
step
.
break?
).
to
be
true
end
end
context
'when pipeline is correct and complete'
do
let
(
:pipeline
)
do
build
(
:ci_pipeline_with_one_job
,
project:
project
)
end
it
'does not invalidate the pipeline'
do
expect
(
pipeline
).
to
be_valid
end
it
'does not break the chain'
do
expect
(
step
.
break?
).
to
be
false
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