Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
8c6e2bad
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
8c6e2bad
编写于
1月 14, 2017
作者:
T
Tomasz Maczukin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add support for docker image configuration in .gitlab-ci.yml
上级
5478ff6d
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
350 addition
and
75 deletion
+350
-75
lib/gitlab/ci/config/entry/docker_image.rb
lib/gitlab/ci/config/entry/docker_image.rb
+31
-0
lib/gitlab/ci/config/entry/image.rb
lib/gitlab/ci/config/entry/image.rb
+8
-1
lib/gitlab/ci/config/entry/service.rb
lib/gitlab/ci/config/entry/service.rb
+35
-0
lib/gitlab/ci/config/entry/services.rb
lib/gitlab/ci/config/entry/services.rb
+24
-1
lib/gitlab/ci/config/entry/validators.rb
lib/gitlab/ci/config/entry/validators.rb
+8
-0
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+16
-16
spec/lib/gitlab/ci/config/entry/global_spec.rb
spec/lib/gitlab/ci/config/entry/global_spec.rb
+6
-6
spec/lib/gitlab/ci/config/entry/image_spec.rb
spec/lib/gitlab/ci/config/entry/image_spec.rb
+87
-26
spec/lib/gitlab/ci/config/entry/job_spec.rb
spec/lib/gitlab/ci/config/entry/job_spec.rb
+1
-1
spec/lib/gitlab/ci/config/entry/service_spec.rb
spec/lib/gitlab/ci/config/entry/service_spec.rb
+117
-0
spec/lib/gitlab/ci/config/entry/services_spec.rb
spec/lib/gitlab/ci/config/entry/services_spec.rb
+17
-24
未找到文件。
lib/gitlab/ci/config/entry/docker_image.rb
0 → 100644
浏览文件 @
8c6e2bad
module
Gitlab
module
Ci
class
Config
module
Entry
module
DockerImage
def
hash?
@config
.
is_a?
(
Hash
)
end
def
string?
@config
.
is_a?
(
String
)
end
def
name
value
[
:name
]
end
def
entrypoint
value
[
:entrypoint
]
end
def
value
return
{
name:
@config
}
if
string?
return
@config
if
hash
?
{}
end
end
end
end
end
end
lib/gitlab/ci/config/entry/image.rb
浏览文件 @
8c6e2bad
...
@@ -7,9 +7,16 @@ module Gitlab
...
@@ -7,9 +7,16 @@ module Gitlab
#
#
class
Image
<
Node
class
Image
<
Node
include
Validatable
include
Validatable
include
DockerImage
ALLOWED_KEYS
=
%i[name entrypoint]
.
freeze
validations
do
validations
do
validates
:config
,
type:
String
validates
:config
,
hash_or_string:
true
validates
:config
,
allowed_keys:
ALLOWED_KEYS
validates
:name
,
type:
String
,
presence:
true
validates
:entrypoint
,
type:
String
,
allow_nil:
true
end
end
end
end
end
end
...
...
lib/gitlab/ci/config/entry/service.rb
0 → 100644
浏览文件 @
8c6e2bad
module
Gitlab
module
Ci
class
Config
module
Entry
##
# Entry that represents a configuration of Docker service.
#
class
Service
<
Node
include
Validatable
include
DockerImage
ALLOWED_KEYS
=
%i[name entrypoint command alias]
.
freeze
validations
do
validates
:config
,
hash_or_string:
true
validates
:config
,
allowed_keys:
ALLOWED_KEYS
validates
:name
,
type:
String
,
presence:
true
validates
:entrypoint
,
type:
String
,
allow_nil:
true
validates
:command
,
type:
String
,
allow_nil:
true
validates
:alias
,
type:
String
,
allow_nil:
true
end
def
alias
value
[
:alias
]
end
def
command
value
[
:command
]
end
end
end
end
end
end
lib/gitlab/ci/config/entry/services.rb
浏览文件 @
8c6e2bad
...
@@ -9,7 +9,30 @@ module Gitlab
...
@@ -9,7 +9,30 @@ module Gitlab
include
Validatable
include
Validatable
validations
do
validations
do
validates
:config
,
array_of_strings:
true
validates
:config
,
type:
Array
end
def
compose!
(
deps
=
nil
)
super
do
@entries
=
[]
@config
.
each
do
|
config
|
@entries
<<
Entry
::
Factory
.
new
(
Entry
::
Service
)
.
value
(
config
||
{})
.
create!
end
@entries
.
each
do
|
entry
|
entry
.
compose!
(
deps
)
end
end
end
def
value
@entries
.
map
(
&
:value
)
end
def
descendants
@entries
end
end
end
end
end
end
...
...
lib/gitlab/ci/config/entry/validators.rb
浏览文件 @
8c6e2bad
...
@@ -44,6 +44,14 @@ module Gitlab
...
@@ -44,6 +44,14 @@ module Gitlab
end
end
end
end
class
HashOrStringValidator
<
ActiveModel
::
EachValidator
def
validate_each
(
record
,
attribute
,
value
)
unless
value
.
is_a?
(
Hash
)
||
value
.
is_a?
(
String
)
record
.
errors
.
add
(
attribute
,
'should be a hash or a string'
)
end
end
end
class
KeyValidator
<
ActiveModel
::
EachValidator
class
KeyValidator
<
ActiveModel
::
EachValidator
include
LegacyValidationHelpers
include
LegacyValidationHelpers
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
浏览文件 @
8c6e2bad
...
@@ -598,8 +598,8 @@ module Ci
...
@@ -598,8 +598,8 @@ module Ci
describe
"Image and service handling"
do
describe
"Image and service handling"
do
it
"returns image and service when defined"
do
it
"returns image and service when defined"
do
config
=
YAML
.
dump
({
config
=
YAML
.
dump
({
image:
"ruby:2.1"
,
image:
{
name:
"ruby:2.1"
}
,
services:
[
"mysql"
],
services:
[
"mysql"
,
{
name:
"docker:dind"
,
alias:
"docker"
}
],
before_script:
[
"pwd"
],
before_script:
[
"pwd"
],
rspec:
{
script:
"rspec"
}
rspec:
{
script:
"rspec"
}
})
})
...
@@ -615,8 +615,8 @@ module Ci
...
@@ -615,8 +615,8 @@ module Ci
coverage_regex:
nil
,
coverage_regex:
nil
,
tag_list:
[],
tag_list:
[],
options:
{
options:
{
image:
"ruby:2.1"
,
image:
{
name:
"ruby:2.1"
}
,
services:
[
"mysql"
]
services:
[
{
name:
"mysql"
},
{
name:
"docker:dind"
,
alias:
"docker"
}
]
},
},
allow_failure:
false
,
allow_failure:
false
,
when:
"on_success"
,
when:
"on_success"
,
...
@@ -630,7 +630,7 @@ module Ci
...
@@ -630,7 +630,7 @@ module Ci
image:
"ruby:2.1"
,
image:
"ruby:2.1"
,
services:
[
"mysql"
],
services:
[
"mysql"
],
before_script:
[
"pwd"
],
before_script:
[
"pwd"
],
rspec:
{
image:
"ruby:2.5"
,
services:
[
"postgresql
"
],
script:
"rspec"
}
rspec:
{
image:
"ruby:2.5"
,
services:
[
{
name:
"postgresql"
},
"docker:dind
"
],
script:
"rspec"
}
})
})
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
,
path
)
config_processor
=
GitlabCiYamlProcessor
.
new
(
config
,
path
)
...
@@ -644,8 +644,8 @@ module Ci
...
@@ -644,8 +644,8 @@ module Ci
coverage_regex:
nil
,
coverage_regex:
nil
,
tag_list:
[],
tag_list:
[],
options:
{
options:
{
image:
"ruby:2.5"
,
image:
{
name:
"ruby:2.5"
}
,
services:
[
"postgresql"
]
services:
[
{
name:
"postgresql"
},
{
name:
"docker:dind"
}
]
},
},
allow_failure:
false
,
allow_failure:
false
,
when:
"on_success"
,
when:
"on_success"
,
...
@@ -884,8 +884,8 @@ module Ci
...
@@ -884,8 +884,8 @@ module Ci
coverage_regex:
nil
,
coverage_regex:
nil
,
tag_list:
[],
tag_list:
[],
options:
{
options:
{
image:
"ruby:2.1"
,
image:
{
name:
"ruby:2.1"
}
,
services:
[
"mysql"
],
services:
[
{
name:
"mysql"
}
],
artifacts:
{
artifacts:
{
name:
"custom_name"
,
name:
"custom_name"
,
paths:
[
"logs/"
,
"binaries/"
],
paths:
[
"logs/"
,
"binaries/"
],
...
@@ -1261,7 +1261,7 @@ EOT
...
@@ -1261,7 +1261,7 @@ EOT
config
=
YAML
.
dump
({
image:
[
"test"
],
rspec:
{
script:
"test"
}
})
config
=
YAML
.
dump
({
image:
[
"test"
],
rspec:
{
script:
"test"
}
})
expect
do
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"image config should be a string"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"image config should be a
hash or a
string"
)
end
end
it
"returns errors if job name is blank"
do
it
"returns errors if job name is blank"
do
...
@@ -1282,35 +1282,35 @@ EOT
...
@@ -1282,35 +1282,35 @@ EOT
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
image:
[
"test"
]
}
})
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
image:
[
"test"
]
}
})
expect
do
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"jobs:rspec:image config should be a string"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"jobs:rspec:image config should be a
hash or a
string"
)
end
end
it
"returns errors if services parameter is not an array"
do
it
"returns errors if services parameter is not an array"
do
config
=
YAML
.
dump
({
services:
"test"
,
rspec:
{
script:
"test"
}
})
config
=
YAML
.
dump
({
services:
"test"
,
rspec:
{
script:
"test"
}
})
expect
do
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"services config should be a
n array of strings
"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"services config should be a
array
"
)
end
end
it
"returns errors if services parameter is not an array of strings"
do
it
"returns errors if services parameter is not an array of strings"
do
config
=
YAML
.
dump
({
services:
[
10
,
"test"
],
rspec:
{
script:
"test"
}
})
config
=
YAML
.
dump
({
services:
[
10
,
"test"
],
rspec:
{
script:
"test"
}
})
expect
do
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"service
s config should be an array of strings
"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"service
config should be a hash or a string
"
)
end
end
it
"returns errors if job services parameter is not an array"
do
it
"returns errors if job services parameter is not an array"
do
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
services:
"test"
}
})
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
services:
"test"
}
})
expect
do
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"jobs:rspec:services config should be a
n array of strings
"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"jobs:rspec:services config should be a
array
"
)
end
end
it
"returns errors if job services parameter is not an array of strings"
do
it
"returns errors if job services parameter is not an array of strings"
do
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
services:
[
10
,
"test"
]
}
})
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
services:
[
10
,
"test"
]
}
})
expect
do
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
jobs:rspec:services config should be an array of strings
"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
service config should be a hash or a string
"
)
end
end
it
"returns error if job configuration is invalid"
do
it
"returns error if job configuration is invalid"
do
...
@@ -1324,7 +1324,7 @@ EOT
...
@@ -1324,7 +1324,7 @@ EOT
config
=
YAML
.
dump
({
extra:
{
script:
'rspec'
,
services:
"test"
}
})
config
=
YAML
.
dump
({
extra:
{
script:
'rspec'
,
services:
"test"
}
})
expect
do
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"jobs:extra:services config should be a
n array of strings
"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"jobs:extra:services config should be a
array
"
)
end
end
it
"returns errors if there are no jobs defined"
do
it
"returns errors if there are no jobs defined"
do
...
...
spec/lib/gitlab/ci/config/entry/global_spec.rb
浏览文件 @
8c6e2bad
...
@@ -95,13 +95,13 @@ describe Gitlab::Ci::Config::Entry::Global do
...
@@ -95,13 +95,13 @@ describe Gitlab::Ci::Config::Entry::Global do
describe
'#image_value'
do
describe
'#image_value'
do
it
'returns valid image'
do
it
'returns valid image'
do
expect
(
global
.
image_value
).
to
eq
'ruby:2.2'
expect
(
global
.
image_value
).
to
eq
(
name:
'ruby:2.2'
)
end
end
end
end
describe
'#services_value'
do
describe
'#services_value'
do
it
'returns array of services'
do
it
'returns array of services'
do
expect
(
global
.
services_value
).
to
eq
[
'postgres:9.1'
,
'mysql:5.5'
]
expect
(
global
.
services_value
).
to
eq
[
{
name:
'postgres:9.1'
},
{
name:
'mysql:5.5'
}
]
end
end
end
end
...
@@ -150,8 +150,8 @@ describe Gitlab::Ci::Config::Entry::Global do
...
@@ -150,8 +150,8 @@ describe Gitlab::Ci::Config::Entry::Global do
script:
%w[rspec ls]
,
script:
%w[rspec ls]
,
before_script:
%w(ls pwd)
,
before_script:
%w(ls pwd)
,
commands:
"ls
\n
pwd
\n
rspec
\n
ls"
,
commands:
"ls
\n
pwd
\n
rspec
\n
ls"
,
image:
'ruby:2.2'
,
image:
{
name:
'ruby:2.2'
}
,
services:
[
'postgres:9.1'
,
'mysql:5.5'
],
services:
[
{
name:
'postgres:9.1'
},
{
name:
'mysql:5.5'
}
],
stage:
'test'
,
stage:
'test'
,
cache:
{
key:
'k'
,
untracked:
true
,
paths:
[
'public/'
]
},
cache:
{
key:
'k'
,
untracked:
true
,
paths:
[
'public/'
]
},
variables:
{
'VAR'
=>
'value'
},
variables:
{
'VAR'
=>
'value'
},
...
@@ -161,8 +161,8 @@ describe Gitlab::Ci::Config::Entry::Global do
...
@@ -161,8 +161,8 @@ describe Gitlab::Ci::Config::Entry::Global do
before_script:
[],
before_script:
[],
script:
%w[spinach]
,
script:
%w[spinach]
,
commands:
'spinach'
,
commands:
'spinach'
,
image:
'ruby:2.2'
,
image:
{
name:
'ruby:2.2'
}
,
services:
[
'postgres:9.1'
,
'mysql:5.5'
],
services:
[
{
name:
'postgres:9.1'
},
{
name:
'mysql:5.5'
}
],
stage:
'test'
,
stage:
'test'
,
cache:
{
key:
'k'
,
untracked:
true
,
paths:
[
'public/'
]
},
cache:
{
key:
'k'
,
untracked:
true
,
paths:
[
'public/'
]
},
variables:
{},
variables:
{},
...
...
spec/lib/gitlab/ci/config/entry/image_spec.rb
浏览文件 @
8c6e2bad
...
@@ -3,43 +3,104 @@ require 'spec_helper'
...
@@ -3,43 +3,104 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Image
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Image
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validation'
do
context
'when configuration is a string'
do
context
'when entry config value is correct'
do
let
(
:config
)
{
'ruby:2.2'
}
let
(
:config
)
{
'ruby:2.2'
}
describe
'#value'
do
describe
'#value'
do
it
'returns image string'
do
it
'returns image hash'
do
expect
(
entry
.
value
).
to
eq
'ruby:2.2'
expect
(
entry
.
value
).
to
eq
({
name:
'ruby:2.2'
})
end
end
end
end
describe
'#errors'
do
it
'does not append errors'
do
expect
(
entry
.
errors
).
to
be_empty
end
end
describe
'#valid?'
do
it
'is valid'
do
expect
(
entry
).
to
be_valid
end
end
describe
'#image'
do
it
"returns image's name"
do
expect
(
entry
.
name
).
to
eq
'ruby:2.2'
end
end
describe
'#errors'
do
describe
'#entrypoint'
do
it
'does not append errors'
do
it
"returns image's entrypoint"
do
expect
(
entry
.
errors
).
to
be_empty
expect
(
entry
.
entrypoint
).
to
be_nil
end
end
end
end
end
describe
'#valid?'
do
context
'when configuration is a hash'
do
it
'is valid'
do
let
(
:config
)
{
{
name:
'ruby:2.2'
,
entrypoint:
'/bin/sh'
}
}
expect
(
entry
).
to
be_valid
end
describe
'#value'
do
it
'returns image hash'
do
expect
(
entry
.
value
).
to
eq
(
config
)
end
end
end
end
context
'when entry value is not correct'
do
describe
'#errors'
do
let
(
:config
)
{
[
'ruby:2.2'
]
}
it
'does not append errors'
do
expect
(
entry
.
errors
).
to
be_empty
end
end
describe
'#valid?'
do
it
'is valid'
do
expect
(
entry
).
to
be_valid
end
end
describe
'#errors'
do
describe
'#image'
do
it
'saves errors'
do
it
"returns image's name"
do
expect
(
entry
.
errors
)
expect
(
entry
.
name
).
to
eq
'ruby:2.2'
.
to
include
'image config should be a string'
end
end
end
end
describe
'#entrypoint'
do
it
"returns image's entrypoint"
do
expect
(
entry
.
entrypoint
).
to
eq
'/bin/sh'
end
end
end
context
'when entry value is not correct'
do
let
(
:config
)
{
[
'ruby:2.2'
]
}
describe
'#errors'
do
it
'saves errors'
do
expect
(
entry
.
errors
)
.
to
include
'image config should be a hash or a string'
end
end
describe
'#valid?'
do
it
'is not valid'
do
expect
(
entry
).
not_to
be_valid
end
end
end
context
'when unexpected key is specified'
do
let
(
:config
)
{
{
name:
'ruby:2.2'
,
non_existing:
'test'
}
}
describe
'#errors'
do
it
'saves errors'
do
expect
(
entry
.
errors
)
.
to
include
'image config contains unknown keys: non_existing'
end
end
describe
'#valid?'
do
describe
'#valid?'
do
it
'is not valid'
do
it
'is not valid'
do
expect
(
entry
).
not_to
be_valid
expect
(
entry
).
not_to
be_valid
end
end
end
end
end
end
end
...
...
spec/lib/gitlab/ci/config/entry/job_spec.rb
浏览文件 @
8c6e2bad
...
@@ -104,7 +104,7 @@ describe Gitlab::Ci::Config::Entry::Job do
...
@@ -104,7 +104,7 @@ describe Gitlab::Ci::Config::Entry::Job do
end
end
it
'overrides global config'
do
it
'overrides global config'
do
expect
(
entry
[
:image
].
value
).
to
eq
'some_image'
expect
(
entry
[
:image
].
value
).
to
eq
(
name:
'some_image'
)
expect
(
entry
[
:cache
].
value
).
to
eq
(
key:
'test'
)
expect
(
entry
[
:cache
].
value
).
to
eq
(
key:
'test'
)
end
end
end
end
...
...
spec/lib/gitlab/ci/config/entry/service_spec.rb
0 → 100644
浏览文件 @
8c6e2bad
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Service
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
before
{
entry
.
compose!
}
context
'when configuration is a string'
do
let
(
:config
)
{
'postgresql:9.5'
}
describe
'#valid?'
do
it
'is valid'
do
expect
(
entry
).
to
be_valid
end
end
describe
'#value'
do
it
'returns valid hash'
do
expect
(
entry
.
value
).
to
include
(
name:
'postgresql:9.5'
)
end
end
describe
'#image'
do
it
"returns service's image name"
do
expect
(
entry
.
name
).
to
eq
'postgresql:9.5'
end
end
describe
'#alias'
do
it
"returns service's alias"
do
expect
(
entry
.
alias
).
to
be_nil
end
end
describe
'#command'
do
it
"returns service's command"
do
expect
(
entry
.
command
).
to
be_nil
end
end
end
context
'when configuration is a hash'
do
let
(
:config
)
do
{
name:
'postgresql:9.5'
,
alias:
'db'
,
command:
'cmd'
,
entrypoint:
'/bin/sh'
}
end
describe
'#valid?'
do
it
'is valid'
do
expect
(
entry
).
to
be_valid
end
end
describe
'#value'
do
it
'returns valid hash'
do
expect
(
entry
.
value
).
to
eq
config
end
end
describe
'#image'
do
it
"returns service's image name"
do
expect
(
entry
.
name
).
to
eq
'postgresql:9.5'
end
end
describe
'#alias'
do
it
"returns service's alias"
do
expect
(
entry
.
alias
).
to
eq
'db'
end
end
describe
'#command'
do
it
"returns service's command"
do
expect
(
entry
.
command
).
to
eq
'cmd'
end
end
describe
'#entrypoint'
do
it
"returns service's entrypoint"
do
expect
(
entry
.
entrypoint
).
to
eq
'/bin/sh'
end
end
end
context
'when entry value is not correct'
do
let
(
:config
)
{
[
'postgresql:9.5'
]
}
describe
'#errors'
do
it
'saves errors'
do
expect
(
entry
.
errors
)
.
to
include
'service config should be a hash or a string'
end
end
describe
'#valid?'
do
it
'is not valid'
do
expect
(
entry
).
not_to
be_valid
end
end
end
context
'when unexpected key is specified'
do
let
(
:config
)
{
{
name:
'postgresql:9.5'
,
non_existing:
'test'
}
}
describe
'#errors'
do
it
'saves errors'
do
expect
(
entry
.
errors
)
.
to
include
'service config contains unknown keys: non_existing'
end
end
describe
'#valid?'
do
it
'is not valid'
do
expect
(
entry
).
not_to
be_valid
end
end
end
end
spec/lib/gitlab/ci/config/entry/services_spec.rb
浏览文件 @
8c6e2bad
...
@@ -3,37 +3,30 @@ require 'spec_helper'
...
@@ -3,37 +3,30 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Services
do
describe
Gitlab
::
Ci
::
Config
::
Entry
::
Services
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validations'
do
before
{
entry
.
compose!
}
context
'when entry config value is correct'
do
let
(
:config
)
{
[
'postgres:9.1'
,
'mysql:5.5'
]
}
describe
'#value'
do
context
'when configuration is valid'
do
it
'returns array of services as is'
do
let
(
:config
)
{
[
'postgresql:9.5'
,
{
name:
'postgresql:9.1'
,
alias:
'postgres_old'
}]
}
expect
(
entry
.
value
).
to
eq
config
end
end
describe
'#valid?'
do
describe
'#valid?'
do
it
'is valid'
do
it
'is valid'
do
expect
(
entry
).
to
be_valid
expect
(
entry
).
to
be_valid
end
end
end
end
end
context
'when entry value is not correct'
do
describe
'#value'
do
let
(
:config
)
{
'ls'
}
it
'returns valid array'
do
expect
(
entry
.
value
).
to
eq
([{
name:
'postgresql:9.5'
},
{
name:
'postgresql:9.1'
,
alias:
'postgres_old'
}])
describe
'#errors'
do
it
'saves errors'
do
expect
(
entry
.
errors
)
.
to
include
'services config should be an array of strings'
end
end
end
end
end
context
'when configuration is invalid'
do
let
(
:config
)
{
'postgresql:9.5'
}
describe
'#valid?'
do
describe
'#valid?'
do
it
'is not valid'
do
it
'is invalid'
do
expect
(
entry
).
not_to
be_valid
expect
(
entry
).
not_to
be_valid
end
end
end
end
end
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录