-
Notifications
You must be signed in to change notification settings - Fork 321
/
Copy pathcompose_v2_spec.rb
120 lines (103 loc) · 2.97 KB
/
compose_v2_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
require 'spec_helper_acceptance'
broken = false
if fact('osfamily') == 'windows'
puts "Not implemented on Windows"
broken = true
elsif fact('osfamily') == 'RedHat'
docker_args = "repo_opt => '--enablerepo=localmirror-extras'"
end
describe 'docker compose', :win_broken => broken do
before(:all) do
install_code = <<-code
class { 'docker': #{docker_args}}
class { 'docker::compose': }
code
apply_manifest(install_code, :catch_failures=>true)
end
describe command("docker-compose --help") do
its(:exit_status) { should eq 0 }
end
context 'Creating compose v2 projects' do
before(:all) do
@install = <<-code
docker_compose { '/tmp/docker-compose-v2.yml':
ensure => present,
}
code
apply_manifest(@install, :catch_failures=>true)
end
it 'should be idempotent' do
apply_manifest(@install, :catch_changes=>true)
end
describe command("docker inspect tmp_compose_test_1"), :sudo => true do
its(:exit_status) { should eq 0 }
end
end
context 'Destroying compose v2 projects' do
before(:all) do
install = <<-code
docker_compose { '/tmp/docker-compose-v2.yml':
ensure => present,
}
code
apply_manifest(install, :catch_failures=>true)
@uninstall = <<-code
docker_compose { '/tmp/docker-compose-v2.yml':
ensure => absent,
}
code
apply_manifest(@uninstall, :catch_failures=>true)
end
it 'should be idempotent' do
apply_manifest(@uninstall, :catch_changes=>true)
end
describe command("docker inspect tmp_compose_test_1"), :sudo => true do
its(:exit_status) { should eq 1 }
end
end
context 'Requesting a specific version of compose' do
before(:all) do
@version = '1.6.2'
@pp = <<-code
class { 'docker::compose':
version => '#{@version}',
}
code
apply_manifest(@pp, :catch_failures=>true)
end
it 'should be idempotent' do
apply_manifest(@pp, :catch_changes=>true)
end
it 'should have installed the requested version' do
shell('docker-compose --version', :acceptable_exit_codes => [0]) do |r|
expect(r.stdout).to match(/#{@version}/)
end
end
end
context 'Removing docker compose' do
before(:all) do
@version = '1.7.0'
@pp = <<-code
class { 'docker::compose':
ensure => absent,
version => '#{@version}',
}
code
apply_manifest(@pp, :catch_failures=>true)
end
it 'should be idempotent' do
apply_manifest(@pp, :catch_changes=>true)
end
it 'should have removed the relevant files' do
shell('test -e /usr/local/bin/docker-compose', :acceptable_exit_codes => [1])
shell("test -e /usr/local/bin/docker-compose-#{@version}", :acceptable_exit_codes => [1])
end
after(:all) do
install_code = <<-code
class { 'docker': }
class { 'docker::compose': }
code
apply_manifest(install_code, :catch_failures=>true)
end
end
end