Skip to content

Commit b69990a

Browse files
(CAT-2484): add integration test for Issue #254 YAML overwrite prevention
Verifies that --fix flag does not corrupt YAML files when processing directories containing both .pp and .yaml files. Signed-off-by: Gavin Didrichsen <[email protected]>
1 parent 6b988a2 commit b69990a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

spec/unit/puppet-lint/bin_spec.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,24 @@ def initialize(args)
615615
end
616616
end
617617

618+
context 'when fixing a directory containing both .pp and .yaml files' do
619+
let(:args) { ['--fix', 'spec/fixtures/test/manifests/issue_254_overwriting_yaml'] }
620+
621+
its(:exitstatus) { is_expected.to eq(1) }
622+
623+
it 'does not overwrite YAML files' do
624+
yaml_file = 'spec/fixtures/test/manifests/issue_254_overwriting_yaml/class_with_dash.yaml'
625+
original_yaml = File.read(yaml_file)
626+
627+
bin # Run the command
628+
629+
yaml_after = File.read(yaml_file)
630+
expect(yaml_after).to eq(original_yaml)
631+
expect(yaml_after).to include('classes:')
632+
expect(yaml_after).not_to include('class foo-bar {')
633+
end
634+
end
635+
618636
context 'when overriding config file options with command line options' do
619637
context 'and config file sets "--only-checks=variable_contains_dash"' do
620638
around(:context) do |example|

0 commit comments

Comments
 (0)