Skip to content

Commit

Permalink
(GH-16) Update tests
Browse files Browse the repository at this point in the history
This commit updates the existing spec tests with examples that
demonstrate how the linter would ignore data type values.
  • Loading branch information
chelnak committed Sep 30, 2022
1 parent 7b48fd1 commit 99852ea
Showing 1 changed file with 76 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
class { '::apache':
timeout => '100',
docroot => '/var/www',
Enum[
'a',
'b',
'c'
] $test = 'c',
}
class{ '::nginx': }
Expand Down Expand Up @@ -70,6 +75,12 @@ class { '::apache':
if $var !~ Mymodule::MyType {
fail("encountered error ${err}")
}
$test = [
'a',
'b',
'c',
],
EOS
}

Expand All @@ -83,7 +94,12 @@ class { '::apache':
<<-EOS
class { '::apache':
timeout => '100',
docroot => '/var/www'
docroot => '/var/www',
Enum[
'a',
'b',
'c'
] $test = 'c'
}
class{ '::nginx': }
Expand Down Expand Up @@ -129,20 +145,27 @@ class { '::apache':
'/etc/baz.conf', '/etc/baz.conf.d'
],
}
$test = [
'a',
'b',
'c'
]
EOS
}

it 'should detect 6 problems' do
expect(problems).to have(6).problems
it 'should detect 7 problems' do
expect(problems).to have(7).problems
end

it 'should create warnings' do
expect(problems).to contain_warning(msg).on_line(3).in_column(32)
expect(problems).to contain_warning(msg).on_line(10).in_column(27)
expect(problems).to contain_warning(msg).on_line(24).in_column(18)
expect(problems).to contain_warning(msg).on_line(33).in_column(23)
expect(problems).to contain_warning(msg).on_line(39).in_column(26)
expect(problems).to contain_warning(msg).on_line(41).in_column(25)
expect(problems).to contain_warning(msg).on_line(8).in_column(24)
expect(problems).to contain_warning(msg).on_line(15).in_column(27)
expect(problems).to contain_warning(msg).on_line(29).in_column(18)
expect(problems).to contain_warning(msg).on_line(38).in_column(23)
expect(problems).to contain_warning(msg).on_line(44).in_column(26)
expect(problems).to contain_warning(msg).on_line(46).in_column(25)
expect(problems).to contain_warning(msg).on_line(58).in_column(14)
end
end

Expand Down Expand Up @@ -223,6 +246,11 @@ class { '::apache':
class { '::apache':
timeout => '100',
docroot => '/var/www',
Enum[
'a',
'b',
'c'
] $test = 'c',
}
class{ '::nginx': }
Expand Down Expand Up @@ -268,6 +296,12 @@ class { '::apache':
'/etc/baz.conf', '/etc/baz.conf.d'
],
}
$test = [
'a',
'b',
'c',
],
EOS
}

Expand All @@ -285,7 +319,12 @@ class { '::apache':
<<-EOS
class { '::apache':
timeout => '100',
docroot => '/var/www'
docroot => '/var/www',
Enum[
'a',
'b',
'c'
] $test = 'c'
}
class{ '::nginx': }
Expand Down Expand Up @@ -331,20 +370,27 @@ class { '::apache':
'/etc/baz.conf', '/etc/baz.conf.d'
],
}
$test = [
'a',
'b',
'c'
]
EOS
}

it 'should detect 6 problems' do
expect(problems).to have(6).problems
it 'should detect 7 problems' do
expect(problems).to have(7).problems
end

it 'should create a warning' do
expect(problems).to contain_fixed(msg).on_line(3).in_column(32)
expect(problems).to contain_fixed(msg).on_line(10).in_column(27)
expect(problems).to contain_fixed(msg).on_line(24).in_column(18)
expect(problems).to contain_fixed(msg).on_line(33).in_column(23)
expect(problems).to contain_fixed(msg).on_line(39).in_column(26)
expect(problems).to contain_fixed(msg).on_line(41).in_column(25)
expect(problems).to contain_fixed(msg).on_line(8).in_column(24)
expect(problems).to contain_fixed(msg).on_line(15).in_column(27)
expect(problems).to contain_fixed(msg).on_line(29).in_column(18)
expect(problems).to contain_fixed(msg).on_line(38).in_column(23)
expect(problems).to contain_fixed(msg).on_line(44).in_column(26)
expect(problems).to contain_fixed(msg).on_line(46).in_column(25)
expect(problems).to contain_fixed(msg).on_line(58).in_column(14)
end

it 'should add trailing commas' do
Expand All @@ -353,6 +399,11 @@ class { '::apache':
class { '::apache':
timeout => '100',
docroot => '/var/www',
Enum[
'a',
'b',
'c'
] $test = 'c',
}
class{ '::nginx': }
Expand Down Expand Up @@ -398,7 +449,13 @@ class { '::apache':
'/etc/baz.conf', '/etc/baz.conf.d'
],
}
EOS
$test = [
'a',
'b',
'c',
]
EOS
)
end
end
Expand Down

0 comments on commit 99852ea

Please sign in to comment.