debian-mirror-gitlab/spec/lib/gitlab/ci/config/entry/image_spec.rb

108 lines
2.3 KiB
Ruby
Raw Normal View History

2016-08-24 12:49:21 +05:30
require 'spec_helper'
2017-08-17 22:00:37 +05:30
describe Gitlab::Ci::Config::Entry::Image do
2016-08-24 12:49:21 +05:30
let(:entry) { described_class.new(config) }
2017-09-10 17:25:29 +05:30
context 'when configuration is a string' do
let(:config) { 'ruby:2.2' }
2016-08-24 12:49:21 +05:30
2017-09-10 17:25:29 +05:30
describe '#value' do
it 'returns image hash' do
expect(entry.value).to eq({ name: 'ruby:2.2' })
2016-08-24 12:49:21 +05:30
end
2017-09-10 17:25:29 +05:30
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
2016-08-24 12:49:21 +05:30
2017-09-10 17:25:29 +05:30
describe '#entrypoint' do
it "returns image's entrypoint" do
expect(entry.entrypoint).to be_nil
2016-08-24 12:49:21 +05:30
end
2017-09-10 17:25:29 +05:30
end
end
2016-08-24 12:49:21 +05:30
2017-09-10 17:25:29 +05:30
context 'when configuration is a hash' do
let(:config) { { name: 'ruby:2.2', entrypoint: %w(/bin/sh run) } }
describe '#value' do
it 'returns image hash' do
expect(entry.value).to eq(config)
2016-08-24 12:49:21 +05:30
end
end
2017-09-10 17:25:29 +05:30
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
2016-08-24 12:49:21 +05:30
2017-09-10 17:25:29 +05:30
describe '#image' do
it "returns image's name" do
expect(entry.name).to eq 'ruby:2.2'
2016-08-24 12:49:21 +05:30
end
2017-09-10 17:25:29 +05:30
end
describe '#entrypoint' do
it "returns image's entrypoint" do
expect(entry.entrypoint).to eq %w(/bin/sh run)
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
2016-08-24 12:49:21 +05:30
2017-09-10 17:25:29 +05:30
describe '#valid?' do
it 'is not valid' do
expect(entry).not_to be_valid
2016-08-24 12:49:21 +05:30
end
end
end
end