diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2017-03-07 16:53:26 +0300 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2017-03-07 16:53:26 +0300 |
commit | fb4a486605e10692b5577f0700fbce38bebcc311 (patch) | |
tree | 975d06a93f4904ae55f4ebc8350b2cb70b7b2b1f /spec/lib/gitlab/ci/build/image_spec.rb | |
parent | 7a774d1a59d7b24b8247e4d67a453388a41c648a (diff) | |
parent | 32b09b8847955052765895063297181835c45b8c (diff) |
Merge branch 'feature/runner-jobs-v4-api' into 'master'
Feature/runner jobs v4 api
Closes #28513
See merge request !9273
Diffstat (limited to 'spec/lib/gitlab/ci/build/image_spec.rb')
-rw-r--r-- | spec/lib/gitlab/ci/build/image_spec.rb | 67 |
1 files changed, 67 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..382385dfd6b --- /dev/null +++ b/spec/lib/gitlab/ci/build/image_spec.rb @@ -0,0 +1,67 @@ +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 'fabricates an object of the proper class' do + is_expected.to be_kind_of(described_class) + end + + it 'populates fabricated object with the proper name attribute' do + expect(subject.name).to eq(image_name) + end + + context 'when image name is empty' do + let(:image_name) { '' } + + it 'does not fabricate an object' do + is_expected.to be_nil + end + end + end + + context 'when image is not defined in job' do + it 'does not fabricate an object' do + is_expected.to be_nil + end + 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 'fabricates an non-empty array of objects' do + is_expected.to be_kind_of(Array) + is_expected.not_to be_empty + expect(subject.first.name).to eq(service_image_name) + end + + context 'when service image name is empty' do + let(:service_image_name) { '' } + + it 'fabricates an empty array' do + is_expected.to be_kind_of(Array) + is_expected.to be_empty + end + end + end + + context 'when services are not defined in job' do + it 'fabricates an empty array' do + is_expected.to be_kind_of(Array) + is_expected.to be_empty + end + end + end +end |