Skip to content

Commit 225a3af

Browse files
committed
Add from-hiera-config to integration
1 parent b0c46ed commit 225a3af

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

spec/octocatalog-diff/integration/hiera5_spec.rb

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
end
2020
end
2121

22-
if ENV['PUPPET_VERSION'].start_with?('3')
22+
if ENV['PUPPET_VERSION'] && ENV['PUPPET_VERSION'].start_with?('3')
2323
# Hiera 5 tests are not applicable
2424
else
2525
context 'with --hiera-path-strip and per-item data directory' do
@@ -79,5 +79,43 @@
7979
expect(to_catalog.resource(type: 'File', title: '/tmp/extra-special')['parameters']).to eq(param4)
8080
end
8181
end
82+
83+
# May be used to catalog-diff a migration from a global hiera file to an environment level one
84+
context 'with --from-hiera-config' do
85+
it 'should succeed in building the catalog and have proper diffs' do
86+
argv = [
87+
'-n', 'rspec-node.github.net',
88+
'--from-hiera-config', 'config/hiera5-global.yaml',
89+
'--from-hiera-path-strip', '/var/lib/puppet'
90+
]
91+
hash = {
92+
spec_fact_file: 'facts.yaml',
93+
spec_repo: 'hiera5'
94+
}
95+
result = OctocatalogDiff::Integration.integration(hash.merge(argv: argv))
96+
expect(result.exitcode).to eq(2), OctocatalogDiff::Integration.format_exception(result)
97+
expect(result.diffs.size).to eq(2)
98+
99+
diff1 = {
100+
diff_type: '~',
101+
type: 'File',
102+
title: '/tmp/common',
103+
structure: %w(parameters content),
104+
old_value: 'Greets from common',
105+
new_value: 'Greets from data/common'
106+
}
107+
expect(OctocatalogDiff::Spec.diff_match?(result.diffs, diff1)).to eq(true)
108+
109+
diff2 = {
110+
diff_type: '~',
111+
type: 'File',
112+
title: '/tmp/nodes',
113+
structure: %w(parameters content),
114+
old_value: 'Greets from nodes',
115+
new_value: 'Greets from data/nodes'
116+
}
117+
expect(OctocatalogDiff::Spec.diff_match?(result.diffs, diff2)).to eq(true)
118+
end
119+
end
82120
end
83121
end

0 commit comments

Comments
 (0)