forked from puppetlabs/puppetlabs-tomcat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwar_spec.rb
More file actions
166 lines (165 loc) · 3.96 KB
/
Copy pathwar_spec.rb
File metadata and controls
166 lines (165 loc) · 3.96 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
require 'spec_helper'
describe 'tomcat::war', :type => :define do
let :pre_condition do
'class { "tomcat": }'
end
let :facts do
{
:osfamily => 'Debian',
:staging_http_get => 'curl',
}
end
let :title do
'sample.war'
end
context 'basic deployment' do
let :params do
{
:war_source => '/tmp/sample.war',
}
end
it { is_expected.to contain_staging__file('sample.war').with(
'source' => '/tmp/sample.war',
'target' => '/opt/apache-tomcat/webapps/sample.war',
)
}
end
context 'basic undeployment' do
let :params do
{
:war_ensure => 'absent'
}
end
it { is_expected.to contain_file('/opt/apache-tomcat/webapps/sample.war').with(
'ensure' => 'absent',
'force' => 'false',
)
}
it { is_expected.to contain_file('/opt/apache-tomcat/webapps/sample').with(
'ensure' => 'absent',
'force' => 'true',
)
}
end
context 'set everything' do
let :params do
{
:catalina_base => '/opt/apache-tomcat/test',
:app_base => 'webapps2',
:war_ensure => 'true',
:war_name => 'sample2.war',
:war_source => '/tmp/sample.war',
}
end
it { is_expected.to contain_staging__file('sample.war').with(
'source' => '/tmp/sample.war',
'target' => '/opt/apache-tomcat/test/webapps2/sample2.war',
)
}
end
context 'set deployment_path' do
let :params do
{
:deployment_path => '/opt/apache-tomcat/webapps3',
:war_source => '/tmp/sample.war',
}
end
it { is_expected.to contain_staging__file('sample.war').with(
'source' => '/tmp/sample.war',
'target' => '/opt/apache-tomcat/webapps3/sample.war',
)
}
end
context 'war_purge is false' do
let :params do
{
:war_ensure => 'absent',
:war_purge => false,
}
end
it { is_expected.to contain_file('/opt/apache-tomcat/webapps/sample.war').with(
'ensure' => 'absent',
'force' => 'false',
)
}
it { is_expected.to_not contain_file('/opt/apache-tomcat/webapps/sample').with(
'ensure' => 'absent',
'force' => 'true',
)
}
end
describe 'failing tests' do
context 'bad war name' do
let :params do
{
:war_name => 'foo',
:war_source => '/tmp/sample.war',
}
end
it do
expect {
is_expected.to compile
}.to raise_error(Puppet::Error, /does not match/)
end
end
context 'bad ensure' do
let :params do
{
:war_ensure => 'foo',
:war_source => '/tmp/sample.war',
}
end
it do
expect {
is_expected.to compile
}.to raise_error(Puppet::Error, /does not match/)
end
end
context 'bad purge' do
let :params do
{
:war_ensure => 'absent',
:war_purge => 'foo',
}
end
it do
expect {
is_expected.to compile
}.to raise_error(Puppet::Error, /is not a boolean/)
end
end
context 'invalid source' do
let :params do
{
:war_source => 'foo',
}
end
it do
expect {
is_expected.to compile
}.to raise_error(Puppet::Error, /not recognize source/)
end
end
context 'no source' do
it do
expect {
is_expected.to compile
}.to raise_error(Puppet::Error, /\$war_source must be specified/)
end
end
context 'both app_base and deployment_path' do
let :params do
{
:war_source => '/tmp/sample.war',
:app_base => 'webapps2',
:deployment_path => '/opt/apache-tomcat/webapps3',
}
end
it do
expect {
is_expected.to compile
}.to raise_error(Puppet::Error, /Only one of \$app_base and \$deployment_path can be specified/)
end
end
end
end