diff options
author | Tomasz Maczukin <tomasz@maczukin.pl> | 2017-03-02 19:44:15 +0300 |
---|---|---|
committer | Tomasz Maczukin <tomasz@maczukin.pl> | 2017-03-02 19:48:00 +0300 |
commit | 5c1aa5fb65ec7474956e6972e40b04b3a967c338 (patch) | |
tree | 9588d71165d0cbc57e56da1c123a201c9d2a5c8e /spec/lib/gitlab/ci/build/image_spec.rb | |
parent | 1bbf2c2cd16140aa95bbf93368209b16795172bd (diff) |
Add some fixes and refactoring after review
Diffstat (limited to 'spec/lib/gitlab/ci/build/image_spec.rb')
-rw-r--r-- | spec/lib/gitlab/ci/build/image_spec.rb | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/build/image_spec.rb b/spec/lib/gitlab/ci/build/image_spec.rb new file mode 100644 index 00000000000..c561e4f40e8 --- /dev/null +++ b/spec/lib/gitlab/ci/build/image_spec.rb @@ -0,0 +1,52 @@ +require 'spec_helper' + +describe Gitlab::Ci::Build::Image do + let(:job) { create(:ci_build, :no_options) } + + describe '#from_image' do + subject { described_class.from_image(job) } + + context 'when image is defined in job' do + let(:image_name) { 'ruby:2.1' } + let(:job) { create(:ci_build, options: { image: image_name } ) } + + it { is_expected.to be_kind_of(described_class) } + it { expect(subject.name).to eq(image_name) } + + context 'when image name is empty' do + let(:image_name) { '' } + + it { is_expected.to eq(nil) } + end + end + + context 'when image is not defined in job' do + it { is_expected.to eq(nil) } + end + end + + describe '#from_services' do + subject { described_class.from_services(job) } + + context 'when services are defined in job' do + let(:service_image_name) { 'postgres' } + let(:job) { create(:ci_build, options: { services: [service_image_name] }) } + + it { is_expected.to be_kind_of(Array) } + it { is_expected.not_to be_empty } + it { expect(subject[0].name).to eq(service_image_name) } + + context 'when service image name is empty' do + let(:service_image_name) { '' } + + it { is_expected.to be_kind_of(Array) } + it { is_expected.to be_empty } + end + end + + context 'when services are not defined in job' do + it { is_expected.to be_kind_of(Array) } + it { is_expected.to be_empty } + end + end +end
\ No newline at end of file |