]> git.donarmstrong.com Git - dsa-puppet.git/blob - 3rdparty/modules/concat/spec/acceptance/fragment_source_spec.rb
try if downgrading to 1.2.2 solves my problem
[dsa-puppet.git] / 3rdparty / modules / concat / spec / acceptance / fragment_source_spec.rb
1 require 'spec_helper_acceptance'
2
3 case fact('osfamily')
4   when 'AIX'
5     username = 'root'
6     groupname = 'system'
7   when 'Darwin'
8     username = 'root'
9     groupname = 'wheel'
10   when 'windows'
11     username = 'Administrator'
12     groupname = 'Administrators'
13   else
14     username = 'root'
15     groupname = 'root'
16 end
17
18 describe 'concat::fragment source' do
19   basedir = default.tmpdir('concat')
20   context 'should read file fragments from local system' do
21     pp = <<-EOS
22       file { '#{basedir}/file1':
23         content => "file1 contents\n"
24       }
25       file { '#{basedir}/file2':
26         content => "file2 contents\n"
27       }
28       concat { '#{basedir}/foo': }
29
30       concat::fragment { '1':
31         target  => '#{basedir}/foo',
32         source  => '#{basedir}/file1',
33         require => File['#{basedir}/file1'],
34       }
35       concat::fragment { '2':
36         target  => '#{basedir}/foo',
37         content => 'string1 contents',
38       }
39       concat::fragment { '3':
40         target  => '#{basedir}/foo',
41         source  => '#{basedir}/file2',
42         require => File['#{basedir}/file2'],
43       }
44     EOS
45
46     it 'applies the manifest twice with no stderr' do
47       apply_manifest(pp, :catch_failures => true)
48       apply_manifest(pp, :catch_changes => true)
49     end
50
51     describe file("#{basedir}/foo") do
52       it { should be_file }
53       its(:content) {
54         should match 'file1 contents'
55         should match 'string1 contents'
56         should match 'file2 contents'
57       }
58     end
59   end # should read file fragments from local system
60
61   context 'should create files containing first match only.' do
62     pp = <<-EOS
63       file { '#{basedir}/file1':
64         content => "file1 contents\n"
65       }
66       file { '#{basedir}/file2':
67         content => "file2 contents\n"
68       }
69       concat { '#{basedir}/result_file1':
70         owner   => '#{username}',
71         group   => '#{groupname}',
72         mode    => '0644',
73       }
74       concat { '#{basedir}/result_file2':
75         owner   => '#{username}',
76         group   => '#{groupname}',
77         mode    => '0644',
78       }
79       concat { '#{basedir}/result_file3':
80         owner   => '#{username}',
81         group   => '#{groupname}',
82         mode    => '0644',
83       }
84
85       concat::fragment { '1':
86         target  => '#{basedir}/result_file1',
87         source  => [ '#{basedir}/file1', '#{basedir}/file2' ],
88         require => [ File['#{basedir}/file1'], File['#{basedir}/file2'] ],
89         order   => '01',
90       }
91       concat::fragment { '2':
92         target  => '#{basedir}/result_file2',
93         source  => [ '#{basedir}/file2', '#{basedir}/file1' ],
94         require => [ File['#{basedir}/file1'], File['#{basedir}/file2'] ],
95         order   => '01',
96       }
97       concat::fragment { '3':
98         target  => '#{basedir}/result_file3',
99         source  => [ '#{basedir}/file1', '#{basedir}/file2' ],
100         require => [ File['#{basedir}/file1'], File['#{basedir}/file2'] ],
101         order   => '01',
102       }
103     EOS
104
105     it 'applies the manifest twice with no stderr' do
106       apply_manifest(pp, :catch_failures => true)
107       apply_manifest(pp, :catch_changes => true)
108     end
109     describe file("#{basedir}/result_file1") do
110       it { should be_file }
111       its(:content) {
112         should match 'file1 contents'
113         should_not match 'file2 contents'
114       }
115     end
116     describe file("#{basedir}/result_file2") do
117       it { should be_file }
118       its(:content) {
119         should match 'file2 contents'
120         should_not match 'file1 contents'
121       }
122     end
123     describe file("#{basedir}/result_file3") do
124       it { should be_file }
125       its(:content) {
126         should match 'file1 contents'
127         should_not match 'file2 contents'
128       }
129     end
130   end
131
132   context 'should fail if no match on source.' do
133     pp = <<-EOS
134       concat { '#{basedir}/fail_no_source':
135         owner   => '#{username}',
136         group   => '#{groupname}',
137         mode    => '0644',
138       }
139
140       concat::fragment { '1':
141         target  => '#{basedir}/fail_no_source',
142         source => [ '#{basedir}/nofilehere', '#{basedir}/nothereeither' ],
143         order   => '01',
144       }
145     EOS
146
147     it 'applies the manifest with resource failures' do
148       apply_manifest(pp, :expect_failures => true)
149     end
150     describe file("#{basedir}/fail_no_source") do
151       #FIXME: Serverspec::Type::File doesn't support exists? for some reason. so... hack.
152       it { should_not be_file }
153       it { should_not be_directory }
154     end
155   end
156 end
157