2019-05-18 00:54:41 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe API::Entities::JobRequest::Image do
|
2019-05-18 00:54:41 +05:30
|
|
|
let(:ports) { [{ number: 80, protocol: 'http', name: 'name' }]}
|
|
|
|
let(:image) { double(name: 'image_name', entrypoint: ['foo'], ports: ports)}
|
|
|
|
let(:entity) { described_class.new(image) }
|
|
|
|
|
|
|
|
subject { entity.as_json }
|
|
|
|
|
|
|
|
it 'returns the image name' do
|
|
|
|
expect(subject[:name]).to eq 'image_name'
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns the entrypoint' do
|
|
|
|
expect(subject[:entrypoint]).to eq ['foo']
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns the ports' do
|
|
|
|
expect(subject[:ports]).to eq ports
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when the ports param is nil' do
|
|
|
|
let(:ports) { nil }
|
|
|
|
|
|
|
|
it 'does not return the ports' do
|
|
|
|
expect(subject[:ports]).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|