Skip to content

Commit 2cfe3a6

Browse files
alexjfishermsalway
authored andcommitted
Add more tests for resource semi-colons
Replaces existing fail cases
1 parent 93c5ec3 commit 2cfe3a6

File tree

3 files changed

+73
-30
lines changed

3 files changed

+73
-30
lines changed

spec/fixtures/fail/semicolon_long.pp

Lines changed: 0 additions & 15 deletions
This file was deleted.

spec/fixtures/fail/semicolon_short.pp

Lines changed: 0 additions & 15 deletions
This file was deleted.

spec/puppet-lint/plugins/check_strict_indent_spec.rb

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
require 'spec_helper'
2+
# rubocop:disable Lint/RedundantRequireStatement
3+
require 'pp'
4+
# rubocop:enable Lint/RedundantRequireStatement
25

36
describe 'strict_indent' do
47
before do
@@ -90,4 +93,74 @@ class () {}
9093
expect(problems).to have(0).problems
9194
end
9295
end
96+
97+
context 'misplaced resource semicolons' do
98+
before do
99+
PuppetLint.configuration.fix = true
100+
end
101+
102+
after do
103+
PuppetLint.configuration.fix = false
104+
end
105+
106+
let(:code) do
107+
<<~EOF
108+
file {
109+
default:
110+
ensure => file,
111+
owner => 'root',
112+
group => 'wheel',
113+
mode => '0600',
114+
;
115+
['ssh_host_dsa_key', 'ssh_host_key', 'ssh_host_rsa_key']:
116+
# use all defaults
117+
;
118+
['ssh_config', 'ssh_host_dsa_key.pub', 'ssh_host_key.pub', 'ssh_host_rsa_key.pub', 'sshd_config']:
119+
# override mode
120+
mode => '0644',
121+
;
122+
}
123+
EOF
124+
end
125+
126+
let(:fixed) do
127+
<<~EOF
128+
file {
129+
default:
130+
ensure => file,
131+
owner => 'root',
132+
group => 'wheel',
133+
mode => '0600',
134+
;
135+
['ssh_host_dsa_key', 'ssh_host_key', 'ssh_host_rsa_key']:
136+
# use all defaults
137+
;
138+
['ssh_config', 'ssh_host_dsa_key.pub', 'ssh_host_key.pub', 'ssh_host_rsa_key.pub', 'sshd_config']:
139+
# override mode
140+
mode => '0644',
141+
;
142+
}
143+
EOF
144+
end
145+
146+
it 'detects three problems' do
147+
expect(problems).to have(3).problem
148+
end
149+
150+
it 'fixes the first problem' do
151+
expect(problems).to contain_fixed('indent should be 2 chars and is 4').on_line(7).in_column(1)
152+
end
153+
154+
it 'fixes the second problem' do
155+
expect(problems).to contain_fixed('indent should be 2 chars and is 4').on_line(10).in_column(1)
156+
end
157+
158+
it 'fixes the third problem' do
159+
expect(problems).to contain_fixed('indent should be 2 chars and is 0').on_line(14).in_column(1)
160+
end
161+
162+
it 'moves the semicolons' do
163+
expect(manifest).to eq fixed
164+
end
165+
end
93166
end

0 commit comments

Comments
 (0)