diff options
author | Tomasz Maczukin <tomasz@maczukin.pl> | 2017-01-14 14:39:53 -0500 |
---|---|---|
committer | Tomasz Maczukin <tomasz@maczukin.pl> | 2017-01-20 15:26:54 +0100 |
commit | eb6aec51ca73319d0714384b28951f32c3096efc (patch) | |
tree | 7c37082dbe2ff62ddd30e96e82d7a0f61994c5b9 /spec | |
parent | bf8e174f0ae21b320c17b5a8f8d45aefcfef9520 (diff) | |
download | gitlab-ce-eb6aec51ca73319d0714384b28951f32c3096efc.tar.gz |
Add support for services configuration in .gitlab-ci.ymlfeature/add-support-for-services-configuration
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/service_spec.rb | 101 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config/entry/services_spec.rb | 41 |
2 files changed, 118 insertions, 24 deletions
diff --git a/spec/lib/gitlab/ci/config/entry/service_spec.rb b/spec/lib/gitlab/ci/config/entry/service_spec.rb new file mode 100644 index 00000000000..e4092bddd0d --- /dev/null +++ b/spec/lib/gitlab/ci/config/entry/service_spec.rb @@ -0,0 +1,101 @@ +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 '#string?' do + it 'is string configuration' do + expect(entry).to be_string + end + end + + describe '#hash?' do + it 'is not hash configuration' do + expect(entry).not_to be_hash + end + 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 include(image: 'postgresql:9.5') + end + end + + describe '#image' do + it 'returns service image' do + expect(entry.image).to eq 'postgresql:9.5' + end + end + + describe '#alias' do + it 'returns service alias' do + expect(entry.alias).to be_nil + end + end + + describe '#command' do + it 'returns service command' do + expect(entry.command).to be_nil + end + end + end + + context 'when configuration is a hash' do + let(:config) do + { image: 'postgresql:9.5', alias: 'db', command: 'cmd' } + end + + describe '#string?' do + it 'is not string configuration' do + expect(entry).not_to be_string + end + end + + describe '#hash?' do + it 'is hash configuration' do + expect(entry).to be_hash + end + 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 image' do + expect(entry.image).to eq 'postgresql:9.5' + end + end + + describe '#alias' do + it 'returns service alias' do + expect(entry.alias).to eq 'db' + end + end + + describe '#command' do + it 'returns service command' do + expect(entry.command).to eq 'cmd' + end + end + end +end diff --git a/spec/lib/gitlab/ci/config/entry/services_spec.rb b/spec/lib/gitlab/ci/config/entry/services_spec.rb index 66fad3b6b16..14986cd4627 100644 --- a/spec/lib/gitlab/ci/config/entry/services_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/services_spec.rb @@ -3,37 +3,30 @@ require 'spec_helper' describe Gitlab::Ci::Config::Entry::Services do let(:entry) { described_class.new(config) } - describe 'validations' do - context 'when entry config value is correct' do - let(:config) { ['postgres:9.1', 'mysql:5.5'] } + before { entry.compose! } - describe '#value' do - it 'returns array of services as is' do - expect(entry.value).to eq config - end - end + context 'when configuration is valid' do + let(:config) { [ 'postgresql:9.5', { image: 'postgresql:9.1', alias: 'postgres_old' } ] } - describe '#valid?' do - it 'is valid' do - expect(entry).to be_valid - end + describe '#valid?' do + it 'is valid' do + expect(entry).to be_valid end end - context 'when entry value is not correct' do - let(:config) { 'ls' } - - describe '#errors' do - it 'saves errors' do - expect(entry.errors) - .to include 'services config should be an array of strings' - end + describe '#value' do + it 'returns valid array' do + expect(entry.value).to eq([{ image: 'postgresql:9.5' }, { image: 'postgresql:9.1', alias: 'postgres_old' }]) end + end + end + + context 'when configuration is invalid' do + let(:config) { 'postgresql:9.5' } - describe '#valid?' do - it 'is not valid' do - expect(entry).not_to be_valid - end + describe '#valid?' do + it 'is invalid' do + expect(entry).not_to be_valid end end end |