]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/concat/spec/acceptance/concat_spec.rb
try if downgrading to 1.2.2 solves my problem
[dsa-puppet.git] / 3rdparty / modules / concat / spec / acceptance / concat_spec.rb
1 require 'spec_helper_acceptance'
2
3 case fact('osfamily')
4   when 'AIX'
5     username = 'root'
6     groupname = 'system'
7     scriptname = 'concatfragments.rb'
8     vardir = default['puppetvardir']
9   when 'Darwin'
10     username = 'root'
11     groupname = 'wheel'
12     scriptname = 'concatfragments.rb'
13     vardir = default['puppetvardir']
14   when 'windows'
15     username = 'Administrator'
16     groupname = 'Administrators'
17     scriptname = 'concatfragments.rb'
18     result = on default, "echo #{default['puppetvardir']}"
19     vardir = result.raw_output.chomp
20   when 'Solaris'
21     username = 'root'
22     groupname = 'root'
23     scriptname = 'concatfragments.rb'
24     vardir = default['puppetvardir']
25   else
26     username = 'root'
27     groupname = 'root'
28     scriptname = 'concatfragments.rb'
29     vardir = default['puppetvardir']
30 end
31
32 describe 'basic concat test' do
33   basedir = default.tmpdir('concat')
34   safe_basedir = basedir.gsub(/[\/:]/, '_')
35
36   shared_examples 'successfully_applied' do |pp|
37     it 'applies the manifest twice with no stderr' do
38       apply_manifest(pp, :catch_failures => true)
39       apply_manifest(pp, :catch_changes => true)
40     end
41
42     describe file("#{vardir}/concat") do
43       it { should be_directory }
44       it { should be_owned_by username }
45       it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
46         should be_mode 755
47       }
48     end
49     describe file("#{vardir}/concat/bin") do
50       it { should be_directory }
51       it { should be_owned_by username }
52       it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
53         should be_mode 755
54       }
55     end
56     describe file("#{vardir}/concat/bin/#{scriptname}") do
57       it { should be_file }
58       it { should be_owned_by username }
59       it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
60         should be_mode 755
61       }
62     end
63     describe file("#{vardir}/concat/#{safe_basedir}_file") do
64       it { should be_directory }
65       it { should be_owned_by username }
66       it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
67         should be_mode 750
68       }
69     end
70     describe file("#{vardir}/concat/#{safe_basedir}_file/fragments") do
71       it { should be_directory }
72       it { should be_owned_by username }
73       it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
74         should be_mode 750
75       }
76     end
77     describe file("#{vardir}/concat/#{safe_basedir}_file/fragments.concat") do
78       it { should be_file }
79       it { should be_owned_by username }
80       it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
81         should be_mode 640
82       }
83     end
84     describe file("#{vardir}/concat/#{safe_basedir}_file/fragments.concat.out") do
85       it { should be_file }
86       it { should be_owned_by username }
87       it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
88         should be_mode 640
89       }
90     end
91   end
92
93   context 'owner/group root' do
94     before(:all) do
95       pp = <<-EOS
96         file { '#{basedir}':
97           ensure => directory,
98         }
99       EOS
100       apply_manifest(pp)
101     end
102     pp = <<-EOS
103       concat { '#{basedir}/file':
104         owner => '#{username}',
105         group => '#{groupname}',
106         mode  => '0644',
107       }
108
109       concat::fragment { '1':
110         target  => '#{basedir}/file',
111         content => '1',
112         order   => '01',
113       }
114
115       concat::fragment { '2':
116         target  => '#{basedir}/file',
117         content => '2',
118         order   => '02',
119       }
120     EOS
121
122     it_behaves_like 'successfully_applied', pp
123
124     describe file("#{basedir}/file") do
125       it { should be_file }
126       it { should be_owned_by username }
127       it("should be group", :unless => (fact('osfamily') == 'windows')) { should be_grouped_into groupname }
128       it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
129         should be_mode 644
130       }
131       its(:content) {
132         should match '1'
133         should match '2'
134       }
135     end
136     describe file("#{vardir}/concat/#{safe_basedir}_file/fragments/01_1") do
137       it { should be_file }
138       it { should be_owned_by username }
139       it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
140         should be_mode 640
141       }
142     end
143     describe file("#{vardir}/concat/#{safe_basedir}_file/fragments/02_2") do
144       it { should be_file }
145       it { should be_owned_by username }
146       it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
147         should be_mode 640
148       }
149     end
150   end
151
152   context 'ensure' do
153     context 'works when set to present with path set' do
154       before(:all) do
155         pp = <<-EOS
156         file { '#{basedir}':
157           ensure => directory,
158         }
159         EOS
160         apply_manifest(pp)
161       end
162       pp="
163         concat { 'file':
164           ensure => present,
165           path   => '#{basedir}/file',
166           mode   => '0644',
167         }
168         concat::fragment { '1':
169           target  => 'file',
170           content => '1',
171           order   => '01',
172         }
173       "
174
175       it_behaves_like 'successfully_applied', pp
176
177       describe file("#{basedir}/file") do
178         it { should be_file }
179         it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
180           should be_mode 644
181         }
182         its(:content) { should match '1' }
183       end
184     end
185     context 'works when set to absent with path set' do
186       before(:all) do
187         pp = <<-EOS
188         file { '#{basedir}':
189           ensure => directory,
190         }
191         EOS
192         apply_manifest(pp)
193       end
194       pp="
195         concat { 'file':
196           ensure => absent,
197           path   => '#{basedir}/file',
198           mode   => '0644',
199         }
200         concat::fragment { '1':
201           target  => 'file',
202           content => '1',
203           order   => '01',
204         }
205       "
206
207       it 'applies the manifest twice with no stderr' do
208         apply_manifest(pp, :catch_failures => true)
209         apply_manifest(pp, :catch_changes => true)
210       end
211
212       describe file("#{basedir}/file") do
213         it { should_not be_file }
214       end
215     end
216   end
217 end