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
Léo-Paul Géneau
gitlab-ce
Commits
d3aa9fef
Commit
d3aa9fef
authored
Jan 02, 2019
by
Paul B
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests(yaml_processor): complete test scenarios on 'include' keyword
parent
30791a36
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
8 deletions
+78
-8
spec/lib/gitlab/ci/config/entry/global_spec.rb
spec/lib/gitlab/ci/config/entry/global_spec.rb
+3
-3
spec/lib/gitlab/ci/yaml_processor_spec.rb
spec/lib/gitlab/ci/yaml_processor_spec.rb
+75
-5
No files found.
spec/lib/gitlab/ci/config/entry/global_spec.rb
View file @
d3aa9fef
...
@@ -13,7 +13,7 @@ describe Gitlab::Ci::Config::Entry::Global do
...
@@ -13,7 +13,7 @@ describe Gitlab::Ci::Config::Entry::Global do
expect
(
described_class
.
nodes
.
keys
)
expect
(
described_class
.
nodes
.
keys
)
.
to
match_array
(
%i[before_script image services
.
to
match_array
(
%i[before_script image services
after_script variables stages
after_script variables stages
types cache]
)
types cache
include
]
)
end
end
end
end
end
end
...
@@ -42,7 +42,7 @@ describe Gitlab::Ci::Config::Entry::Global do
...
@@ -42,7 +42,7 @@ describe Gitlab::Ci::Config::Entry::Global do
end
end
it
'creates node object for each entry'
do
it
'creates node object for each entry'
do
expect
(
global
.
descendants
.
count
).
to
eq
8
expect
(
global
.
descendants
.
count
).
to
eq
9
end
end
it
'creates node object using valid class'
do
it
'creates node object using valid class'
do
...
@@ -189,7 +189,7 @@ describe Gitlab::Ci::Config::Entry::Global do
...
@@ -189,7 +189,7 @@ describe Gitlab::Ci::Config::Entry::Global do
describe
'#nodes'
do
describe
'#nodes'
do
it
'instantizes all nodes'
do
it
'instantizes all nodes'
do
expect
(
global
.
descendants
.
count
).
to
eq
8
expect
(
global
.
descendants
.
count
).
to
eq
9
end
end
it
'contains unspecified nodes'
do
it
'contains unspecified nodes'
do
...
...
spec/lib/gitlab/ci/yaml_processor_spec.rb
View file @
d3aa9fef
...
@@ -603,11 +603,81 @@ module Gitlab
...
@@ -603,11 +603,81 @@ module Gitlab
end
end
describe
"Include"
do
describe
"Include"
do
it
"does not return any error with a valid configuration"
do
let
(
:opts
)
{
{}
}
config
=
YAML
.
dump
({
include:
"/local.gitlab-ci.yml"
})
expect
do
let
(
:config
)
do
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
{
end
.
not_to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
)
include:
include_content
,
rspec:
{
script:
"test"
}
}
end
subject
{
Gitlab
::
Ci
::
YamlProcessor
.
new
(
YAML
.
dump
(
config
),
opts
)
}
context
"when validating a ci config file with no project context"
do
context
"when an array is provided"
do
let
(
:include_content
)
{
[
"/local.gitlab-ci.yml"
]
}
it
"does not return any error"
do
expect
{
subject
}.
not_to
raise_error
end
end
context
"when an array of wrong keyed object is provided"
do
let
(
:include_content
)
{
[{
yolo:
"/local.gitlab-ci.yml"
}]
}
it
"returns a validation error"
do
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
)
end
end
context
"when an array of mixed typed objects is provided"
do
let
(
:include_content
)
do
[
'https://gitlab.com/awesome-project/raw/master/.before-script-template.yml'
,
'/templates/.after-script-template.yml'
,
{
template:
'Auto-DevOps.gitlab-ci.yml'
}
]
end
it
"does not return any error"
do
expect
{
subject
}.
not_to
raise_error
end
end
context
"when the include type is incorrect"
do
let
(
:include_content
)
{
{
name:
"/local.gitlab-ci.yml"
}
}
it
"returns an invalid configuration error"
do
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
)
end
end
end
context
"when validating a ci config file within a project"
do
let
(
:include_content
)
{
"/local.gitlab-ci.yml"
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:opts
)
{
{
project:
project
,
sha:
project
.
commit
.
sha
}
}
context
"when the included internal file is present"
do
before
do
expect
(
project
.
repository
).
to
receive
(
:blob_data_at
)
.
and_return
(
YAML
.
dump
({
job1:
{
script:
'hello'
}
}))
end
it
"does not return an error"
do
expect
{
subject
}.
not_to
raise_error
end
end
context
"when the included internal file is not present"
do
it
"returns an error with missing file details"
do
expect
{
subject
}.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
"Local file `
#{
include_content
}
` does not exist!"
)
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