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
Boxiang Sun
gitlab-ce
Commits
de2e8d4a
Commit
de2e8d4a
authored
Aug 24, 2016
by
Katarzyna Kobierska
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for yaml content with errors
parent
ca1f5ede
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
spec/requests/api/lint_spec.rb
spec/requests/api/lint_spec.rb
+17
-11
No files found.
spec/requests/api/lint_spec.rb
View file @
de2e8d4a
...
...
@@ -3,30 +3,36 @@ require 'spec_helper'
describe
API
::
API
do
include
ApiHelpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:yaml_content
)
do
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/gitlab_ci.yml'
))
end
describe
'POST /lint'
do
context
'with valid .gitlab-ci.yaml content'
do
context
'authorized user'
do
it
'validate content'
do
post
api
(
'/lint'
),
{
content:
yaml_content
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Hash
expect
(
json_response
[
'status'
]).
to
eq
(
'valid'
)
end
it
'validates content'
do
post
api
(
'/lint'
),
{
content:
yaml_content
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
).
to
be_an
Hash
expect
(
json_response
[
'status'
]).
to
eq
(
'valid'
)
end
end
context
'with invalid .gitlab_ci.yml
content
'
do
it
'validate
content
'
do
context
'with invalid .gitlab_ci.yml'
do
it
'validate
s content and shows correct errors
'
do
post
api
(
'/lint'
),
{
content:
'invalid content'
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'status'
]).
to
eq
(
'invalid'
)
expect
(
json_response
[
'errors'
]).
to
eq
([
'Invalid configuration format'
])
end
it
"validates content and shows configuration error"
do
post
api
(
'/lint'
),
{
content:
'{ image: "ruby:2.1", services: ["postgres"] }'
}
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'status'
]).
to
eq
(
'invalid'
)
expect
(
json_response
[
'errors'
]).
to
eq
([
'jobs config should contain at least one visible job'
])
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