]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/concat/spec/acceptance/deprecation_warnings_spec.rb
try if downgrading to 1.2.2 solves my problem
[dsa-puppet.git] / 3rdparty / modules / concat / spec / acceptance / deprecation_warnings_spec.rb
1 require 'spec_helper_acceptance'
2
3 describe 'deprecation warnings' do
4   basedir = default.tmpdir('concat')
5
6   shared_examples 'has_warning' do |pp, w|
7     it 'applies the manifest twice with a stderr regex' do
8       expect(apply_manifest(pp, :catch_failures => true).stderr).to match(/#{Regexp.escape(w)}/m)
9       expect(apply_manifest(pp, :catch_changes => true).stderr).to match(/#{Regexp.escape(w)}/m)
10     end
11   end
12
13   context 'concat gnu parameter' do
14     pp = <<-EOS
15       concat { '#{basedir}/file':
16         gnu => 'foo',
17       }
18       concat::fragment { 'foo':
19         target  => '#{basedir}/file',
20         content => 'bar',
21       }
22     EOS
23     w = 'The $gnu parameter to concat is deprecated and has no effect'
24
25     it_behaves_like 'has_warning', pp, w
26   end
27
28   context 'concat warn parameter =>' do
29     ['true', 'yes', 'on'].each do |warn|
30       context warn do
31         pp = <<-EOS
32           concat { '#{basedir}/file':
33             warn => '#{warn}',
34           }
35           concat::fragment { 'foo':
36             target  => '#{basedir}/file',
37             content => 'bar',
38           }
39         EOS
40         w = 'Using stringified boolean values (\'true\', \'yes\', \'on\', \'false\', \'no\', \'off\') to represent boolean true/false as the $warn parameter to concat is deprecated and will be treated as the warning message in a future release'
41
42         it_behaves_like 'has_warning', pp, w
43
44         describe file("#{basedir}/file") do
45           it { should be_file }
46           its(:content) {
47             should match '# This file is managed by Puppet. DO NOT EDIT.'
48             should match 'bar'
49           }
50         end
51       end
52     end
53
54     ['false', 'no', 'off'].each do |warn|
55       context warn do
56         pp = <<-EOS
57           concat { '#{basedir}/file':
58             warn => '#{warn}',
59           }
60           concat::fragment { 'foo':
61             target  => '#{basedir}/file',
62             content => 'bar',
63           }
64         EOS
65         w = 'Using stringified boolean values (\'true\', \'yes\', \'on\', \'false\', \'no\', \'off\') to represent boolean true/false as the $warn parameter to concat is deprecated and will be treated as the warning message in a future release'
66
67         it_behaves_like 'has_warning', pp, w
68
69         describe file("#{basedir}/file") do
70           it { should be_file }
71           its(:content) {
72             should_not match '# This file is managed by Puppet. DO NOT EDIT.'
73             should match 'bar'
74           }
75         end
76       end
77     end
78   end
79
80   context 'concat::fragment ensure parameter', :unless => fact('osfamily') == 'windows' do
81     context 'target file exists' do
82       before(:all) do
83         pp = <<-EOS
84           file { '#{basedir}':
85             ensure => directory,
86           }
87           file { '#{basedir}/file1':
88             content => "file1 contents\n",
89           }
90         EOS
91         apply_manifest(pp)
92       end
93
94       pp = <<-EOS
95         concat { '#{basedir}/file': }
96         concat::fragment { 'foo':
97           target => '#{basedir}/file',
98           ensure => '#{basedir}/file1',
99         }
100       EOS
101       w = 'Passing a value other than \'present\' or \'absent\' as the $ensure parameter to concat::fragment is deprecated.  If you want to use the content of a file as a fragment please use the $source parameter.'
102
103       it_behaves_like 'has_warning', pp, w
104
105       describe file("#{basedir}/file") do
106         it { should be_file }
107         its(:content) { should match 'file1 contents' }
108       end
109
110       describe 'the fragment can be changed from a symlink to a plain file', :unless => (fact("osfamily") == "windows") do
111         pp = <<-EOS
112           concat { '#{basedir}/file': }
113           concat::fragment { 'foo':
114             target  => '#{basedir}/file',
115             content => 'new content',
116           }
117         EOS
118
119         it 'applies the manifest twice with no stderr' do
120           apply_manifest(pp, :catch_failures => true)
121           apply_manifest(pp, :catch_changes => true)
122         end
123
124         describe file("#{basedir}/file") do
125           it { should be_file }
126           its(:content) {
127             should match 'new content'
128             should_not match 'file1 contents'
129           }
130         end
131       end
132     end # target file exists
133
134     context 'target does not exist', :unless => fact('osfamily') == 'windows' do
135       pp = <<-EOS
136         concat { '#{basedir}/file': }
137         concat::fragment { 'foo':
138           target => '#{basedir}/file',
139           ensure => '#{basedir}/file1',
140         }
141       EOS
142       w = 'Passing a value other than \'present\' or \'absent\' as the $ensure parameter to concat::fragment is deprecated.  If you want to use the content of a file as a fragment please use the $source parameter.'
143
144       it_behaves_like 'has_warning', pp, w
145
146       describe file("#{basedir}/file") do
147         it { should be_file }
148       end
149
150       describe 'the fragment can be changed from a symlink to a plain file', :unless => (fact('osfamily') == 'windows') do
151         pp = <<-EOS
152           concat { '#{basedir}/file': }
153           concat::fragment { 'foo':
154             target  => '#{basedir}/file',
155             content => 'new content',
156           }
157         EOS
158
159         it 'applies the manifest twice with no stderr' do
160           apply_manifest(pp, :catch_failures => true)
161           apply_manifest(pp, :catch_changes => true)
162         end
163
164         describe file("#{basedir}/file") do
165           it { should be_file }
166           its(:content) { should match 'new content' }
167         end
168       end
169     end # target file exists
170
171   end # concat::fragment ensure parameter
172
173   context 'concat::fragment mode parameter' do
174     pp = <<-EOS
175       concat { '#{basedir}/file': }
176       concat::fragment { 'foo':
177         target  => '#{basedir}/file',
178         content => 'bar',
179         mode    => 'bar',
180       }
181     EOS
182     w = 'The $mode parameter to concat::fragment is deprecated and has no effect'
183
184     it_behaves_like 'has_warning', pp, w
185   end
186
187   context 'concat::fragment owner parameter' do
188     pp = <<-EOS
189       concat { '#{basedir}/file': }
190       concat::fragment { 'foo':
191         target  => '#{basedir}/file',
192         content => 'bar',
193         owner   => 'bar',
194       }
195     EOS
196     w = 'The $owner parameter to concat::fragment is deprecated and has no effect'
197
198     it_behaves_like 'has_warning', pp, w
199   end
200
201   context 'concat::fragment group parameter' do
202     pp = <<-EOS
203       concat { '#{basedir}/file': }
204       concat::fragment { 'foo':
205         target  => '#{basedir}/file',
206         content => 'bar',
207         group   => 'bar',
208       }
209     EOS
210     w = 'The $group parameter to concat::fragment is deprecated and has no effect'
211
212     it_behaves_like 'has_warning', pp, w
213   end
214
215   context 'concat::fragment backup parameter' do
216     pp = <<-EOS
217       concat { '#{basedir}/file': }
218       concat::fragment { 'foo':
219         target  => '#{basedir}/file',
220         content => 'bar',
221         backup  => 'bar',
222       }
223     EOS
224     w = 'The $backup parameter to concat::fragment is deprecated and has no effect'
225
226     it_behaves_like 'has_warning', pp, w
227   end
228
229   context 'include concat::setup' do
230     pp = <<-EOS
231       include concat::setup
232     EOS
233     w = 'concat::setup is deprecated as a public API of the concat module and should no longer be directly included in the manifest.'
234
235     it_behaves_like 'has_warning', pp, w
236   end
237
238 end