forked from puppetlabs/puppetlabs-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmachine_spec.rb
132 lines (115 loc) · 4.18 KB
/
machine_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
require 'spec_helper'
describe 'docker::machine', type: :class do
let(:facts) do
{
kernel: 'Linux',
osfamily: 'Debian',
operatingsystem: 'Ubuntu',
lsbdistid: 'Ubuntu',
lsbdistcodename: 'maverick',
kernelrelease: '3.8.0-29-generic',
operatingsystemrelease: '10.04',
operatingsystemmajrelease: '10',
}
end
it { is_expected.to compile }
context 'with defaults for all parameters' do
it { is_expected.to compile.with_all_deps }
it {
is_expected.to contain_exec('Install Docker Machine 0.16.1').with(
'path' => '/usr/bin/',
'cwd' => '/tmp',
'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',
'creates' => '/usr/local/bin/docker-machine-0.16.1',
'require' => 'Package[curl]',
)
}
it {
is_expected.to contain_file('/usr/local/bin/docker-machine-0.16.1').with(
'owner' => 'root',
'mode' => '0755',
'require' => 'Exec[Install Docker Machine 0.16.1]',
)
}
it {
is_expected.to contain_file('/usr/local/bin/docker-machine').with(
'ensure' => 'link',
'target' => '/usr/local/bin/docker-machine-0.16.1',
'require' => 'File[/usr/local/bin/docker-machine-0.16.1]',
)
}
end
context 'with ensure => absent' do
let(:params) { { ensure: 'absent' } }
it { is_expected.to contain_file('/usr/local/bin/docker-machine-0.16.1').with_ensure('absent') }
it { is_expected.to contain_file('/usr/local/bin/docker-machine').with_ensure('absent') }
end
context 'when no proxy is provided' do
let(:params) { { version: '0.16.0' } }
it {
is_expected.to contain_exec('Install Docker Machine 0.16.0').with_command(
'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',
)
}
end
context 'when proxy is provided' do
let(:params) do
{ proxy: 'http://proxy.example.org:3128/',
version: '0.16.0' }
end
it { is_expected.to compile }
it {
is_expected.to contain_exec('Install Docker Machine 0.16.0').with_command(
'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',
)
}
end
context 'when proxy is not a http proxy' do
let(:params) { { proxy: 'this is not a URL' } }
it do
expect {
is_expected.to compile
}.to raise_error(%r{does not match})
end
end
context 'when proxy contains username and password' do
let(:params) do
{ proxy: 'http://user:[email protected]:3128/',
version: '0.16.0' }
end
it { is_expected.to compile }
it {
is_expected.to contain_exec('Install Docker Machine 0.16.0').with_command(
'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',
)
}
end
context 'when proxy IP is provided' do
let(:params) do
{ proxy: 'http://10.10.10.10:3128/',
version: '0.16.0' }
end
it { is_expected.to compile }
it {
is_expected.to contain_exec('Install Docker Machine 0.16.0').with_command(
'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',
)
}
end
context 'with docker_machine_url is provided' do
let(:params) do
{
version: '0.16.2',
url: 'https://gitlab-docker-machine-downloads.s3.amazonaws.com/v0.16.2-gitlab.3/docker-machine',
}
end
it { is_expected.to compile }
it {
is_expected.to contain_exec('Install Docker Machine 0.16.2').with_command(
'curl -s -S -L https://gitlab-docker-machine-downloads.s3.amazonaws.com/v0.16.2-gitlab.3/docker-machine -o /usr/local/bin/docker-machine-0.16.2',
)
}
end
end