Skip to content

Commit e8262ce

Browse files
author
Kevin Paulisse
committed
Add test for hiera config in the environment
1 parent 15049e3 commit e8262ce

7 files changed

Lines changed: 47 additions & 3 deletions

File tree

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
:backends:
3+
- yaml
4+
:yaml:
5+
:datadir: /var/lib/puppet/environments/%{::environment}/hieradata
6+
:hierarchy:
7+
- common
8+
:merge_behavior: deeper
9+
:logger: console
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
bar::param: 'Value from one/hieradata/common.yaml'

spec/octocatalog-diff/fixtures/repos/preserve-environments/environments/one/modules/bar/manifests/init.pp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
class bar {
1+
class bar (
2+
$param = '',
3+
) {
24
include sitetest
35

46
file { '/tmp/bar':
@@ -9,4 +11,8 @@
911
file { '/tmp/bar-static.txt':
1012
source => 'puppet:///modules/bar/bar-static.txt',
1113
}
14+
15+
file { '/tmp/bar-param.txt':
16+
content => "one ${param}",
17+
}
1218
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
:backends:
3+
- yaml
4+
:yaml:
5+
:datadir: /var/lib/puppet/environments/%{::environment}/hieradata
6+
:hierarchy:
7+
- common
8+
:merge_behavior: deeper
9+
:logger: console
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
bar::param: 'Value from two/hieradata/common.yaml'

spec/octocatalog-diff/fixtures/repos/preserve-environments/environments/two/modules/bar/manifests/init.pp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
class bar {
1+
class bar (
2+
$param = '',
3+
) {
24
include sitetest
35

46
file { '/tmp/bar':
@@ -9,4 +11,8 @@
911
file { '/tmp/bar-static.txt':
1012
source => 'puppet:///modules/bar/bar-static.txt',
1113
}
14+
15+
file { '/tmp/bar-param.txt':
16+
content => "two ${param}",
17+
}
1218
}

spec/octocatalog-diff/integration/preserve_environments_spec.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,17 @@
137137
'--preserve-environments',
138138
'--from-environment', 'one',
139139
'--to-environment', 'two',
140-
'--create-symlinks', 'modules,site'
140+
'--create-symlinks', 'modules,site',
141+
'--hiera-config', 'hiera.yaml',
142+
'--hiera-path-strip', '/var/lib/puppet'
141143
]
142144
)
143145
end
144146

145147
it 'should exit without error' do
146148
expect(@result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(@result)
147149
expect(@result.exception).to be_nil, OctocatalogDiff::Integration.format_exception(@result)
150+
expect(@result.diffs.any?).to eq(true), OctocatalogDiff::Integration.format_exception(@result)
148151
end
149152

150153
it 'should display proper diffs' do
@@ -178,6 +181,13 @@
178181
)
179182
).to eq(true)
180183
end
184+
185+
it 'should handle hieradata properly' do
186+
h = @result.diffs.select { |x| x[1] == "File\f/tmp/bar-param.txt\fparameters\fcontent" }
187+
expect(h.size).to eq(1), h.inspect
188+
expect(h.first[2]).to eq('one Value from one/hieradata/common.yaml')
189+
expect(h.first[3]).to eq('two Value from two/hieradata/common.yaml')
190+
end
181191
end
182192

183193
context 'to modules' do

0 commit comments

Comments
 (0)