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
e5cbc641
Commit
e5cbc641
authored
Dec 11, 2019
by
drew cimino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Specs and rescue fix for Ci::YamlProcessor#validation_errors
parent
4eb665dd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
6 deletions
+44
-6
lib/gitlab/ci/yaml_processor.rb
lib/gitlab/ci/yaml_processor.rb
+4
-6
spec/lib/gitlab/ci/yaml_processor_spec.rb
spec/lib/gitlab/ci/yaml_processor_spec.rb
+40
-0
No files found.
lib/gitlab/ci/yaml_processor.rb
View file @
e5cbc641
...
@@ -108,12 +108,10 @@ module Gitlab
...
@@ -108,12 +108,10 @@ module Gitlab
config
=
Gitlab
::
Ci
::
Config
.
new
(
content
,
**
opts
)
config
=
Gitlab
::
Ci
::
Config
.
new
(
content
,
**
opts
)
return
config
.
errors
unless
config
.
valid?
return
config
.
errors
unless
config
.
valid?
begin
Gitlab
::
Ci
::
YamlProcessor
.
new
(
content
,
opts
)
Gitlab
::
Ci
::
YamlProcessor
.
new
(
content
,
opts
)
[]
[]
rescue
ValidationError
,
Gitlab
::
Ci
::
Config
::
ConfigError
=>
e
rescue
ValidationError
=>
e
[
e
.
message
]
[
e
.
message
]
end
end
end
private
private
...
...
spec/lib/gitlab/ci/yaml_processor_spec.rb
View file @
e5cbc641
...
@@ -2235,6 +2235,46 @@ module Gitlab
...
@@ -2235,6 +2235,46 @@ module Gitlab
it
{
is_expected
.
to
be_nil
}
it
{
is_expected
.
to
be_nil
}
end
end
end
end
describe
'#validation_errors'
do
subject
{
Gitlab
::
Ci
::
YamlProcessor
.
validation_errors
(
content
)
}
context
'when the YAML could not be parsed'
do
let
(
:content
)
{
YAML
.
dump
(
'invalid: yaml: test'
)
}
it
{
is_expected
.
to
eq
([
'Invalid configuration format'
])
}
end
context
'when the tags parameter is invalid'
do
let
(
:content
)
{
YAML
.
dump
({
rspec:
{
script:
'test'
,
tags:
'mysql'
}
})
}
it
{
is_expected
.
to
eq
([
'jobs:rspec:tags config should be an array of strings'
])
}
end
context
'when the configuration contains multiple keyword-syntax errors'
do
let
(
:content
)
{
YAML
.
dump
({
rspec:
{
script:
'test'
,
bad_tags:
'mysql'
,
rules:
{
wrong:
'format'
}
}
})
}
it
{
is_expected
.
to
eq
([
'jobs:rspec config contains unknown keys: bad_tags'
,
'jobs:rspec rules should be an array of hashes'
])
}
end
context
'when YAML content is empty'
do
let
(
:content
)
{
''
}
it
{
is_expected
.
to
eq
([
'Please provide content of .gitlab-ci.yml'
])
}
end
context
'when the YAML contains an unknown alias'
do
let
(
:content
)
{
'steps: *bad_alias'
}
it
{
is_expected
.
to
eq
([
'Unknown alias: bad_alias'
])
}
end
context
'when the YAML is valid'
do
let
(
:content
)
{
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/gitlab_ci.yml'
))
}
it
{
is_expected
.
to
be_empty
}
end
end
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