Skip to content

Commit 6c979ea

Browse files
alexjfishermsalway
authored andcommitted
Add more tests for resource semi-colons
1 parent 93c5ec3 commit 6c979ea

File tree

1 file changed

+70
-0
lines changed

1 file changed

+70
-0
lines changed

spec/puppet-lint/plugins/check_strict_indent_spec.rb

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

0 commit comments

Comments
 (0)