From e425048beedd04dd9a16ee27fb26b6197dc14970 Mon Sep 17 00:00:00 2001 From: Craig Gumbley Date: Fri, 30 Sep 2022 20:32:54 +0100 Subject: [PATCH] (GH-16) Update tests This commit updates the existing spec tests with examples that demonstrate how the linter would ignore data type values. --- .../check_trailing_comma_spec.rb | 95 +++++++++++++++---- 1 file changed, 76 insertions(+), 19 deletions(-) diff --git a/spec/puppet-lint/plugins/check_trailing_comma/check_trailing_comma_spec.rb b/spec/puppet-lint/plugins/check_trailing_comma/check_trailing_comma_spec.rb index 7dd02b8..92d381a 100644 --- a/spec/puppet-lint/plugins/check_trailing_comma/check_trailing_comma_spec.rb +++ b/spec/puppet-lint/plugins/check_trailing_comma/check_trailing_comma_spec.rb @@ -10,6 +10,11 @@ class { '::apache': timeout => '100', docroot => '/var/www', + Enum[ + 'a', + 'b', + 'c' + ] $test = 'c', } class{ '::nginx': } @@ -70,6 +75,12 @@ class { '::apache': if $var !~ Mymodule::MyType { fail("encountered error ${err}") } + + $test = [ + 'a', + 'b', + 'c', + ], EOS } @@ -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': } @@ -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 @@ -223,6 +246,11 @@ class { '::apache': class { '::apache': timeout => '100', docroot => '/var/www', + Enum[ + 'a', + 'b', + 'c' + ] $test = 'c', } class{ '::nginx': } @@ -268,6 +296,12 @@ class { '::apache': '/etc/baz.conf', '/etc/baz.conf.d' ], } + + $test = [ + 'a', + 'b', + 'c', + ], EOS } @@ -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': } @@ -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 @@ -353,6 +399,11 @@ class { '::apache': class { '::apache': timeout => '100', docroot => '/var/www', + Enum[ + 'a', + 'b', + 'c' + ] $test = 'c', } class{ '::nginx': } @@ -398,7 +449,13 @@ class { '::apache': '/etc/baz.conf', '/etc/baz.conf.d' ], } - EOS + + $test = [ + 'a', + 'b', + 'c', + ] + EOS ) end end