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
39856150
Commit
39856150
authored
Aug 17, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add feature tests for CI/CD `extends` keyword
parent
2725433a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
0 deletions
+76
-0
spec/lib/gitlab/ci/config_spec.rb
spec/lib/gitlab/ci/config_spec.rb
+16
-0
spec/lib/gitlab/ci/yaml_processor_spec.rb
spec/lib/gitlab/ci/yaml_processor_spec.rb
+60
-0
No files found.
spec/lib/gitlab/ci/config_spec.rb
View file @
39856150
...
...
@@ -107,5 +107,21 @@ describe Gitlab::Ci::Config do
end
end
end
context
'when invalid extended hash has been provided'
do
let
(
:yml
)
do
<<-
EOS
test:
extends: test
script: rspec
EOS
end
it
'raises an error'
do
expect
{
config
}.
to
raise_error
(
described_class
::
ConfigError
,
/Circular dependency detected/
)
end
end
end
end
spec/lib/gitlab/ci/yaml_processor_spec.rb
View file @
39856150
...
...
@@ -562,6 +562,58 @@ module Gitlab
end
end
context
'when using `extends`'
do
let
(
:config_processor
)
{
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
}
subject
{
config_processor
.
builds
.
first
}
context
'when using simple `extends`'
do
let
(
:config
)
do
<<~
YAML
.template:
script: test
rspec:
extends: .template
image: ruby:alpine
YAML
end
it
'correctly extends rspec job'
do
expect
(
config_processor
.
builds
).
to
be_one
expect
(
subject
.
dig
(
:commands
)).
to
eq
'test'
expect
(
subject
.
dig
(
:options
,
:image
,
:name
)).
to
eq
'ruby:alpine'
end
end
context
'when using recursive `extends`'
do
let
(
:config
)
do
<<~
YAML
rspec:
extends: .test
script: rspec
when: always
.template:
before_script:
- bundle install
.test:
extends: .template
script: test
image: image:test
YAML
end
it
'correctly extends rspec job'
do
expect
(
config_processor
.
builds
).
to
be_one
expect
(
subject
.
dig
(
:commands
)).
to
eq
"bundle install
\n
rspec"
expect
(
subject
.
dig
(
:options
,
:image
,
:name
)).
to
eq
'image:test'
expect
(
subject
.
dig
(
:when
)).
to
eq
'always'
end
end
end
describe
"When"
do
%w(on_success on_failure always)
.
each
do
|
when_state
|
it
"returns
#{
when_state
}
when defined"
do
...
...
@@ -1309,6 +1361,14 @@ module Gitlab
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
'jobs:rspec:only variables invalid expression syntax'
)
end
it
'returns errors if extended hash configuration is invalid'
do
config
=
YAML
.
dump
({
rspec:
{
extends:
'something'
,
script:
'test'
}
})
expect
{
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
}
.
to
raise_error
(
Gitlab
::
Ci
::
YamlProcessor
::
ValidationError
,
'Unknown extends key in extended `rspec`!'
)
end
end
describe
"Validate configuration templates"
do
...
...
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