Skip to content

Commit e1d2762

Browse files
committed
Create integration for fact override regexes
1 parent 2a5029e commit e1d2762

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

spec/octocatalog-diff/integration/fact_override_spec.rb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,46 @@
221221
expect(@result.stderr).to match(/Diffs computed for rspec-node.github.net/)
222222
end
223223
end
224+
225+
describe 'fact override with regexp' do
226+
before(:all) do
227+
@result = OctocatalogDiff::Integration.integration(
228+
spec_repo: 'fact-overrides',
229+
spec_fact_file: 'valid-facts.yaml',
230+
argv: [
231+
'--to-fact-override', '/pad+res/=10.30.50.70', # Will match ipaddress
232+
'--to-fact-override', '/qdn/=(nil)', # Will match fqdn
233+
'--to-fact-override', '/asdflk/=(nil)', # Will match no facts
234+
'--fact-override', 'foofoo=barbar', # Should ultimately affect only from-catalog
235+
'--no-parallel'
236+
]
237+
)
238+
@diffs = OctocatalogDiff::Spec.remove_file_and_line(@result[:diffs]).map do |x|
239+
x[2].delete('tags') if x[2].is_a?(Hash)
240+
x
241+
end
242+
end
243+
244+
it 'should succeed' do
245+
expect(@result[:exitcode]).not_to eq(-1), "Internal error: #{@result[:exception]}\n#{@result[:logs]}"
246+
expect(@result[:exitcode]).to eq(2), "Runtime error: #{@result[:logs]}"
247+
end
248+
249+
it 'should show ip address change' do
250+
pending 'catalog-diff failed' unless @result[:exitcode] == 2
251+
this_diff = ['~', "File\f/tmp/ipaddress\fparameters\fcontent", '10.20.30.40', '10.30.50.70']
252+
expect(@diffs).to include(this_diff)
253+
end
254+
255+
it 'should not remove foofoo in the new catalog' do
256+
pending 'catalog-diff failed' unless @result[:exitcode] == 2
257+
expect(@diffs.select { |diff| diff[1] =~ /foofoo/ }).to eq([])
258+
end
259+
260+
it 'should show correct log messages' do
261+
expect(@result.logs).to match(/Override fqdn from "rspec-node.xyz.github.net" to nil/)
262+
expect(@result.logs).to match(/Override foofoo from nil to "barbar"/)
263+
expect(@result.logs).to match(/Override ipaddress from "10.20.30.40" to "10.30.50.70"/)
264+
expect(@result.logs).not_to match(/Override asdflk/)
265+
end
266+
end

0 commit comments

Comments
 (0)