forked from puppetlabs/puppetlabs-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_windows_spec.rb
executable file
·88 lines (80 loc) · 5 KB
/
run_windows_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
require 'spec_helper'
describe 'docker::run', :type => :define do
let(:title) { 'sample' }
let(:facts) { {
:architecture => 'amd64',
:osfamily => 'windows',
:operatingsystem => 'windows',
:kernelrelease => '10.0.14393',
:operatingsystemrelease => '2016',
:operatingsystemmajrelease => '2016',
:os => { :family => 'windows', :name => 'windows', :release => { :major => '2016', :full => '2016' } }
} }
command = 'docker'
context 'with restart policy set to no' do
let(:params) { {'restart' => 'no', 'command' => 'command', 'image' => 'base', 'extra_parameters' => '-c 4'} }
it { should contain_exec('run sample with docker') }
it { should contain_exec('run sample with docker').with_unless(/sample/) }
it { should contain_exec('run sample with docker').with_unless(/inspect/) }
it { should contain_exec('run sample with docker').with_command(/--cidfile=c:\/Windows\/Temp\/docker-sample.cid/) }
it { should contain_exec('run sample with docker').with_command(/-c 4/) }
it { should contain_exec('run sample with docker').with_command(/--restart="no"/) }
it { should contain_exec('run sample with docker').with_command(/base command/) }
it { should contain_exec('run sample with docker').with_timeout(3000) }
end
context 'with restart policy set to always' do
let(:params) { {'restart' => 'always', 'command' => 'command', 'image' => 'base', 'extra_parameters' => '-c 4'} }
it { should contain_exec('run sample with docker') }
it { should contain_exec('run sample with docker').with_unless(/sample/) }
it { should contain_exec('run sample with docker').with_unless(/inspect/) }
it { should contain_exec('run sample with docker').with_command(/--cidfile=c:\/Windows\/Temp\/docker-sample.cid/) }
it { should contain_exec('run sample with docker').with_command(/-c 4/) }
it { should contain_exec('run sample with docker').with_command(/--restart="always"/) }
it { should contain_exec('run sample with docker').with_command(/base command/) }
it { should contain_exec('run sample with docker').with_timeout(3000) }
end
context 'with restart policy set to on-failure' do
let(:params) { {'restart' => 'on-failure', 'command' => 'command', 'image' => 'base', 'extra_parameters' => '-c 4'} }
it { should contain_exec('run sample with docker') }
it { should contain_exec('run sample with docker').with_unless(/sample/) }
it { should contain_exec('run sample with docker').with_unless(/inspect/) }
it { should contain_exec('run sample with docker').with_command(/--cidfile=c:\/Windows\/Temp\/docker-sample.cid/) }
it { should contain_exec('run sample with docker').with_command(/-c 4/) }
it { should contain_exec('run sample with docker').with_command(/--restart="on-failure"/) }
it { should contain_exec('run sample with docker').with_command(/base command/) }
it { should contain_exec('run sample with docker').with_timeout(3000) }
end
context 'with restart policy set to on-failure:3' do
let(:params) { {'restart' => 'on-failure:3', 'command' => 'command', 'image' => 'base', 'extra_parameters' => '-c 4'} }
it { should contain_exec('run sample with docker') }
it { should contain_exec('run sample with docker').with_unless(/sample/) }
it { should contain_exec('run sample with docker').with_unless(/inspect/) }
it { should contain_exec('run sample with docker').with_command(/--cidfile=c:\/Windows\/Temp\/docker-sample.cid/) }
it { should contain_exec('run sample with docker').with_command(/-c 4/) }
it { should contain_exec('run sample with docker').with_command(/--restart="on-failure:3"/) }
it { should contain_exec('run sample with docker').with_command(/base command/) }
it { should contain_exec('run sample with docker').with_timeout(3000) }
end
context 'with ensure absent' do
let(:params) { {'ensure' => 'absent', 'command' => 'command', 'image' => 'base'} }
it { should compile.with_all_deps }
it { should contain_exec("stop container docker-sample").with_command('docker stop --time=0 sample') }
it { should contain_exec("remove container docker-sample").with_command('docker rm -v sample') }
it { should_not contain_file('c:/Windows/Temp/docker-sample.cid"')}
end
context 'with ensure absent and restart policy' do
let(:params) { {'ensure' => 'absent', 'command' => 'command', 'image' => 'base', 'restart' => 'always'} }
it { should compile.with_all_deps }
it { should contain_exec("stop sample with docker").with_command('docker stop --time=0 sample') }
it { should contain_exec("remove sample with docker").with_command('docker rm -v sample') }
it { should_not contain_file('c:/Windows/Temp/docker-sample.cid"')}
end
context 'with ensure present and no restart policy' do
let(:params) { {'ensure' => 'present', 'image' => 'base'} }
it do
expect {
should_not contain_file('c:/Windows/Temp/docker-sample.cid"')
}.to raise_error(Puppet::Error)
end
end
end