Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tests for multi body file bad modes selector #1

Open
wants to merge 1 commit into
base: issue-663
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions spec/puppet-lint/plugins/check_resources/file_mode_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,26 @@
expect(problems).to have(0).problems
end
end

context 'multi body file bad modes selector' do
let(:code) { "
file {
'/tmp/foo1':
ensure => $foo ? { default => absent },
mode => 644;
'/tmp/foo2':
mode => 644;
'/tmp/foo3':
mode => 644;
}"
}

it 'should create three warnings' do
expect(problems).to contain_warning(sprintf(msg)).on_line(5).in_column(21)
expect(problems).to contain_warning(sprintf(msg)).on_line(7).in_column(21)
expect(problems).to contain_warning(sprintf(msg)).on_line(9).in_column(21)
end
end
end

context 'with fix enabled' do
Expand Down Expand Up @@ -225,5 +245,25 @@
expect(manifest).to eq(code)
end
end

context 'multi body file bad modes selector' do
let(:code) { "
file {
'/tmp/foo1':
ensure => $foo ? { default => absent },
mode => 644;
'/tmp/foo2':
mode => 644;
'/tmp/foo3':
mode => 644;
}"
}

it 'should fix the manifest' do
expect(problems).to contain_fixed(msg).on_line(5).in_column(21)
expect(problems).to contain_fixed(msg).on_line(7).in_column(21)
expect(problems).to contain_fixed(msg).on_line(9).in_column(21)
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@
expect(problems).to have(0).problems
end
end

context 'multi body file bad modes selector' do
let(:code) { "
file {
'/tmp/foo1':
ensure => $foo ? { default => absent },
mode => 644;
'/tmp/foo2':
mode => 644;
'/tmp/foo3':
mode => 644;
}"
}

it 'should create three warnings' do
expect(problems).to contain_warning(sprintf(msg)).on_line(5).in_column(21)
expect(problems).to contain_warning(sprintf(msg)).on_line(7).in_column(21)
expect(problems).to contain_warning(sprintf(msg)).on_line(9).in_column(21)
end
end
end

context 'with fix enabled' do
Expand Down Expand Up @@ -89,5 +109,25 @@
expect(manifest).to eq(code)
end
end

context 'multi body file bad modes selector' do
let(:code) { "
file {
'/tmp/foo1':
ensure => $foo ? { default => absent },
mode => 644;
'/tmp/foo2':
mode => 644;
'/tmp/foo3':
mode => 644;
}"
}

it 'should fix the manifest' do
expect(problems).to contain_fixed(msg).on_line(5).in_column(21)
expect(problems).to contain_fixed(msg).on_line(7).in_column(21)
expect(problems).to contain_fixed(msg).on_line(9).in_column(21)
end
end
end
end