forked from puppetlabs/puppetlabs-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstack_spec.rb
67 lines (62 loc) · 2.7 KB
/
stack_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
require 'spec_helper'
['Debian', 'Windows'].each do |osfamily|
describe 'docker::stack', :type => :define do
let(:title) { 'test_stack' }
if osfamily == 'Debian'
let(:facts) { {
:osfamily => 'Debian',
:operatingsystem => 'Debian',
:lsbdistid => 'Debian',
:lsbdistcodename => 'jessie',
:kernelrelease => '3.2.0-4-amd64',
:operatingsystemmajrelease => '8',
} }
elsif osfamily == 'Windows'
let(:facts) { {
:osfamily => 'windows',
:operatingsystem => 'windows',
:kernelrelease => '10.0.14393',
:operatingsystemmajrelease => '2016',
:docker_program_data_path => 'C:/ProgramData',
:docker_program_files_path => 'C:/Program Files',
:docker_systemroot => 'C:/Windows',
:docker_user_temp_path => 'C:/Users/Administrator/AppData/Local/Temp',
} }
end
context 'Create stack with compose file' do
let(:params) { {
'stack_name' => 'foo',
'compose_files' => ['/tmp/docker-compose.yaml'],
'resolve_image' => 'always',
} }
it { should contain_exec('docker stack create foo').with_command(/docker stack deploy/) }
it { should contain_exec('docker stack create foo').with_command(/--compose-file '\/tmp\/docker-compose.yaml'/) }
end
context 'Create stack with multiple compose files' do
let(:params) { {
'stack_name' => 'foo',
'compose_files' => ['/tmp/docker-compose.yaml', '/tmp/docker-compose-2.yaml'],
'resolve_image' => 'always',
} }
it { should contain_exec('docker stack create foo').with_command(/docker stack deploy/) }
it { should contain_exec('docker stack create foo').with_command(/--compose-file '\/tmp\/docker-compose.yaml'/) }
it { should contain_exec('docker stack create foo').with_command(/--compose-file '\/tmp\/docker-compose-2.yaml'/) }
end
context 'with prune' do
let(:params) { {
'stack_name' => 'foo',
'compose_files' => ['/tmp/docker-compose.yaml'],
'prune' => true,
} }
it { should contain_exec('docker stack create foo').with_command(/docker stack deploy/) }
it { should contain_exec('docker stack create foo').with_command(/--compose-file '\/tmp\/docker-compose.yaml'/) }
it { should contain_exec('docker stack create foo').with_command(/--prune/) }
end
context 'with ensure => absent' do
let(:params) { {
'ensure' => 'absent',
'stack_name' => 'foo'} }
it { should contain_exec('docker stack destroy foo').with_command(/docker stack rm/) }
end
end
end