Page MenuHomeSoftware Heritage

exec_spec.rb
No OneTemporary

exec_spec.rb

require 'spec_helper'
describe 'docker::exec', type: :define do
let(:title) { 'sample' }
let(:facts) do
{
osfamily: 'Debian',
operatingsystem: 'Debian',
lsbdistid: 'Debian',
lsbdistcodename: 'jessie',
kernelrelease: '3.2.0-4-amd64',
operatingsystemmajrelease: '8',
os: { distro: { codename: 'jessie' }, family: 'Debian', name: 'Debian', release: { major: '8', full: '8.2' } },
}
end
context 'when running detached' do
let(:params) { { 'command' => 'command', 'container' => 'container', 'detach' => true } }
it { is_expected.to contain_exec('docker exec --detach=true container command') }
end
context 'when running with tty' do
let(:params) { { 'command' => 'command', 'container' => 'container', 'tty' => true } }
it { is_expected.to contain_exec('docker exec --tty=true container command') }
end
context 'when running with interactive' do
let(:params) { { 'command' => 'command', 'container' => 'container', 'interactive' => true } }
it { is_expected.to contain_exec('docker exec --interactive=true container command') }
end
context 'when running with onlyif "running"' do
let(:params) { { 'command' => 'command', 'container' => 'container', 'interactive' => true, 'onlyif' => 'running' } }
it { is_expected.to contain_exec('docker exec --interactive=true container command').with_onlyif 'docker ps --no-trunc --format=\'table {{.Names}}\' | grep \'^container$\'' }
end
context 'when running without onlyif custom command' do
let(:params) { { 'command' => 'command', 'container' => 'container', 'interactive' => true, 'onlyif' => 'custom' } }
it { is_expected.to contain_exec('docker exec --interactive=true container command').with_onlyif 'custom' }
end
context 'when running without onlyif' do
let(:params) { { 'command' => 'command', 'container' => 'container', 'interactive' => true } }
it { is_expected.to contain_exec('docker exec --interactive=true container command').with_onlyif nil }
end
context 'when running with unless' do
let(:params) { { 'command' => 'command', 'container' => 'container', 'interactive' => true, 'unless' => 'some_command arg1' } }
it { is_expected.to contain_exec('docker exec --interactive=true container command').with_unless 'docker exec --interactive=true container some_command arg1' }
end
context 'when running without unless' do
let(:params) { { 'command' => 'command', 'container' => 'container', 'interactive' => true } }
it { is_expected.to contain_exec('docker exec --interactive=true container command').with_unless nil }
end
context 'with title that need sanitisation' do
let(:params) { { 'command' => 'command', 'container' => 'container_sample/1', 'detach' => true, 'sanitise_name' => true } }
it { is_expected.to contain_exec('docker exec --detach=true container_sample-1 command') }
end
context 'with environment variables passed to exec' do
let(:params) { { 'command' => 'command', 'container' => 'container', 'env' => ['FOO=BAR', 'FOO2=BAR2'] } }
it { is_expected.to contain_exec('docker exec --env FOO=BAR --env FOO2=BAR2 container command') }
end
end

File Metadata

Mime Type
text/x-ruby
Expires
Sat, Jun 21, 7:19 PM (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3409762

Event Timeline