1 require 'spec_helper_acceptance'
7 scriptname = 'concatfragments.rb'
8 vardir = default.puppet['vardir']
9 if vardir.nil? or vardir == ''
10 vardir = '/opt/puppetlabs/puppet/cache'
15 scriptname = 'concatfragments.rb'
16 vardir = default.puppet['vardir']
17 if vardir.nil? or vardir == ''
18 vardir = '/opt/puppetlabs/puppet/cache'
21 username = 'Administrator'
22 groupname = 'Administrators'
23 scriptname = 'concatfragments.rb'
24 result = on default, "echo #{default.puppet['vardir']}"
25 vardir = result.raw_output.chomp
29 scriptname = 'concatfragments.rb'
30 vardir = default.puppet['vardir']
31 if vardir.nil? or vardir == ''
32 vardir = '/opt/puppetlabs/puppet/cache'
37 scriptname = 'concatfragments.rb'
38 vardir = default.puppet['vardir']
39 if vardir.nil? or vardir == ''
40 vardir = '/opt/puppetlabs/puppet/cache'
44 describe 'basic concat test' do
45 basedir = default.tmpdir('concat')
46 safe_basedir = basedir.gsub(/[\/:]/, '_')
48 shared_examples 'successfully_applied' do |pp|
49 it 'applies the manifest twice with no stderr' do
50 apply_manifest(pp, :catch_failures => true)
51 apply_manifest(pp, :catch_changes => true)
55 context 'owner/group root' do
65 concat { '#{basedir}/file':
66 owner => '#{username}',
67 group => '#{groupname}',
71 concat::fragment { '1':
72 target => '#{basedir}/file',
77 concat::fragment { '2':
78 target => '#{basedir}/file',
84 it_behaves_like 'successfully_applied', pp
86 describe file("#{basedir}/file") do
88 it { should be_owned_by username }
89 it("should be group", :unless => (fact('osfamily') == 'windows')) { should be_grouped_into groupname }
90 it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
101 context 'works when set to present with path set' do
113 path => '#{basedir}/file',
116 concat::fragment { '1':
123 it_behaves_like 'successfully_applied', pp
125 describe file("#{basedir}/file") do
126 it { should be_file }
127 it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
130 its(:content) { should match '1' }
133 context 'works when set to absent with path set' do
145 path => '#{basedir}/file',
148 concat::fragment { '1':
155 it 'applies the manifest twice with no stderr' do
156 apply_manifest(pp, :catch_failures => true)
157 apply_manifest(pp, :catch_changes => true)
160 describe file("#{basedir}/file") do
161 it { should_not be_file }
164 context 'works when set to present with path that has special characters' do
165 filename = fact('osfamily') == 'windows' ? 'file(1)' : 'file(1:2)'
176 concat { '#{filename}':
178 path => '#{basedir}/#{filename}',
181 concat::fragment { '1':
182 target => '#{filename}',
188 it_behaves_like 'successfully_applied', pp
190 describe file("#{basedir}/#{filename}") do
191 it { should be_file }
192 it("should be mode", :unless => (fact('osfamily') == 'AIX' or fact('osfamily') == 'windows')) {
195 its(:content) { should match '1' }
198 context 'noop properly' do
210 path => '#{basedir}/file',
214 concat::fragment { '1':
221 it_behaves_like 'successfully_applied', pp
223 describe file("#{basedir}/file") do
224 it { should_not be_file }