|
| 1 | +require 'spec_helper' |
| 2 | + |
| 3 | +describe 'docker::machine', :type => :class do |
| 4 | + let(:facts) do |
| 5 | + { |
| 6 | + :kernel => 'Linux', |
| 7 | + :osfamily => 'Debian', |
| 8 | + :operatingsystem => 'Ubuntu', |
| 9 | + :lsbdistid => 'Ubuntu', |
| 10 | + :lsbdistcodename => 'maverick', |
| 11 | + :kernelrelease => '3.8.0-29-generic', |
| 12 | + :operatingsystemrelease => '10.04', |
| 13 | + :operatingsystemmajrelease => '10', |
| 14 | + } |
| 15 | + end |
| 16 | + |
| 17 | + it { is_expected.to compile } |
| 18 | + |
| 19 | + context 'with defaults for all parameters' do |
| 20 | + it { should compile.with_all_deps } |
| 21 | + it { should contain_exec('Install Docker Machine 0.16.1').with( |
| 22 | + 'path' => '/usr/bin/', |
| 23 | + 'cwd' => '/tmp', |
| 24 | + 'command' => 'curl -s -S -L https://github.com/docker/machine/releases/download/v0.16.1/docker-machine-Linux-x86_64 -o /usr/local/bin/docker-machine-0.16.1', |
| 25 | + 'creates' => '/usr/local/bin/docker-machine-0.16.1', |
| 26 | + 'require' => 'Package[curl]' |
| 27 | + )} |
| 28 | + it { should contain_file('/usr/local/bin/docker-machine-0.16.1').with( |
| 29 | + 'owner' => 'root', |
| 30 | + 'mode' => '0755', |
| 31 | + 'require' => 'Exec[Install Docker Machine 0.16.1]' |
| 32 | + )} |
| 33 | + it { should contain_file('/usr/local/bin/docker-machine').with( |
| 34 | + 'ensure' => 'link', |
| 35 | + 'target' => '/usr/local/bin/docker-machine-0.16.1', |
| 36 | + 'require' => 'File[/usr/local/bin/docker-machine-0.16.1]' |
| 37 | + )} |
| 38 | + end |
| 39 | + |
| 40 | + context 'with ensure => absent' do |
| 41 | + let (:params) { { :ensure => 'absent' } } |
| 42 | + it { should contain_file('/usr/local/bin/docker-machine-0.16.1').with_ensure('absent') } |
| 43 | + it { should contain_file('/usr/local/bin/docker-machine').with_ensure('absent') } |
| 44 | + end |
| 45 | + |
| 46 | + context 'when no proxy is provided' do |
| 47 | + let(:params) { {:version => '0.16.0'} } |
| 48 | + it { is_expected.to contain_exec('Install Docker Machine 0.16.0').with_command( |
| 49 | + 'curl -s -S -L https://github.com/docker/machine/releases/download/v0.16.0/docker-machine-Linux-x86_64 -o /usr/local/bin/docker-machine-0.16.0') |
| 50 | + } |
| 51 | + end |
| 52 | + |
| 53 | + context 'when proxy is provided' do |
| 54 | + let(:params) { {:proxy => 'http://proxy.example.org:3128/', |
| 55 | + :version => '0.16.0'} } |
| 56 | + it { is_expected.to compile } |
| 57 | + it { is_expected.to contain_exec('Install Docker Machine 0.16.0').with_command( |
| 58 | + 'curl -s -S -L --proxy http://proxy.example.org:3128/ https://github.com/docker/machine/releases/download/v0.16.0/docker-machine-Linux-x86_64 -o /usr/local/bin/docker-machine-0.16.0') |
| 59 | + } |
| 60 | + end |
| 61 | + |
| 62 | + context 'when proxy is not a http proxy' do |
| 63 | + let(:params) { {:proxy => 'this is not a URL'} } |
| 64 | + it do |
| 65 | + expect { |
| 66 | + is_expected.to compile |
| 67 | + }.to raise_error(/does not match/) |
| 68 | + end |
| 69 | + end |
| 70 | + |
| 71 | + context 'when proxy contains username and password' do |
| 72 | + let(:params) { {:proxy => 'http://user:[email protected]:3128/', |
| 73 | + :version => '0.16.0'} } |
| 74 | + it { is_expected.to compile } |
| 75 | + it { is_expected.to contain_exec('Install Docker Machine 0.16.0').with_command( |
| 76 | + 'curl -s -S -L --proxy http://user:[email protected]:3128/ https://github.com/docker/machine/releases/download/v0.16.0/docker-machine-Linux-x86_64 -o /usr/local/bin/docker-machine-0.16.0') |
| 77 | + } |
| 78 | + end |
| 79 | + |
| 80 | + context 'when proxy IP is provided' do |
| 81 | + let(:params) { {:proxy => 'http://10.10.10.10:3128/', |
| 82 | + :version => '0.16.0'} } |
| 83 | + it { is_expected.to compile } |
| 84 | + it { is_expected.to contain_exec('Install Docker Machine 0.16.0').with_command( |
| 85 | + 'curl -s -S -L --proxy http://10.10.10.10:3128/ https://github.com/docker/machine/releases/download/v0.16.0/docker-machine-Linux-x86_64 -o /usr/local/bin/docker-machine-0.16.0') |
| 86 | + } |
| 87 | + end |
| 88 | +end |
0 commit comments