Skip to content

Commit c2772ea

Browse files
committed
(CAT-2121) Update tests to account for validate changes
1 parent 66644df commit c2772ea

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

spec/acceptance/report_spec.rb

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
before(:all) do
1010
File.open(init_pp, 'w') do |f|
1111
f.puts <<~EOS
12-
class report {}
12+
class report
1313
EOS
1414
end
1515
end
@@ -18,24 +18,24 @@ class report {}
1818
include_context 'with a fake TTY'
1919
# Tests writing reports to a file
2020
describe command('pdk validate puppet manifests/init.pp --format=text:report.txt') do
21-
its(:exit_status) { is_expected.to eq(0) }
21+
its(:exit_status) { is_expected.to eq(1) }
2222
its(:stdout) { is_expected.to have_no_output }
2323
its(:stderr) { is_expected.to match(/Checking Puppet manifest syntax/i) }
2424
its(:stderr) { is_expected.to match(/Checking Puppet manifest style/i) }
2525

2626
describe file('report.txt') do
2727
it { is_expected.to exist }
28-
# pdk (WARNING): puppet-lint: class not documented (manifests/init.pp:1:1)
29-
its(:content) { is_expected.to match(/\(warning\):.*class not documented.*\(#{Regexp.escape(init_pp)}.*\)/i) }
28+
# pdk (ERROR): puppet-syntax: Could not parse for environment production: Syntax error at end of input (manifests/init.pp)
29+
its(:content) { is_expected.to match(/\(ERROR\):.*Could not parse for environment production.*\(#{Regexp.escape(init_pp)}.*\)/i) }
3030
end
3131
end
3232

3333
# Tests writing reports to stdout doesn't actually write a file named stdout
3434
describe command('pdk validate puppet manifests/init.pp --format=text:stdout') do
35-
its(:exit_status) { is_expected.to eq(0) }
35+
its(:exit_status) { is_expected.to eq(1) }
3636
its(:stderr) { is_expected.to match(/Checking Puppet manifest syntax/i) }
3737
its(:stderr) { is_expected.to match(/Checking Puppet manifest style/i) }
38-
its(:stdout) { is_expected.to match(/\(warning\):.*class not documented.*\(#{Regexp.escape(init_pp)}.*\)/i) }
38+
its(:stdout) { is_expected.to match(/\(ERROR\):.*Could not parse for environment production.*\(#{Regexp.escape(init_pp)}.*\)/i) }
3939

4040
describe file('stdout') do
4141
it { is_expected.not_to exist }
@@ -44,15 +44,15 @@ class report {}
4444

4545
# Tests writing reports to stderr doesn't actually write a file named stderr
4646
describe command('pdk validate puppet manifests/init.pp --format=text:stderr') do
47-
its(:exit_status) { is_expected.to eq(0) }
47+
its(:exit_status) { is_expected.to eq(1) }
4848
its(:stdout) { is_expected.to have_no_output }
4949
its(:stderr) { is_expected.to match(/Checking Puppet manifest syntax/i) }
5050
its(:stderr) { is_expected.to match(/Checking Puppet manifest style/i) }
5151

5252
its(:stderr) do
5353
# Due to spinners writing at arbitrary cursor locations, we can't depend on the text
5454
# being at a the beginning of a line.
55-
is_expected.to match(/\(warning\):.*class not documented.*\(#{Regexp.escape(init_pp)}.*\)/i)
55+
is_expected.to match(/\(ERROR\):.*Could not parse for environment production.*\(#{Regexp.escape(init_pp)}.*\)/i)
5656
end
5757

5858
describe file('stderr') do
@@ -63,10 +63,10 @@ class report {}
6363

6464
context 'when not run interactively' do
6565
describe command('pdk validate puppet manifests/init.pp') do
66-
its(:exit_status) { is_expected.to eq(0) }
66+
its(:exit_status) { is_expected.to eq(1) }
6767
its(:stderr) { is_expected.to match(/using ruby \d+\.\d+\.\d+/i) }
6868
its(:stderr) { is_expected.to match(/using puppet \d+\.\d+\.\d+/i) }
69-
its(:stdout) { is_expected.to match(/\(warning\):.*class not documented.*\(#{Regexp.escape(init_pp)}.*\)/i) }
69+
its(:stdout) { is_expected.to match(/\(ERROR\):.*Could not parse for environment production.*\(#{Regexp.escape(init_pp)}.*\)/i) }
7070
end
7171
end
7272
end

spec/acceptance/validate_puppet_spec.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class foo {
8181
end
8282

8383
describe command('pdk validate puppet --format text:stdout --format junit:report.xml') do
84-
its(:exit_status) { is_expected.to eq(0) }
84+
its(:exit_status) { is_expected.to eq(1) }
8585
its(:stderr) { is_expected.not_to match(epp_spinner_text) }
8686
its(:stderr) { is_expected.to match(syntax_spinner_text) }
8787
its(:stderr) { is_expected.to match(lint_spinner_text) }
@@ -180,7 +180,10 @@ class foo {
180180
context 'with a parsable file and some style warnings' do
181181
before(:all) do
182182
File.open(init_pp, 'w') do |f|
183-
f.puts 'class foo {}'
183+
f.puts <<-EOS.gsub(/^ {10}/, '')
184+
# pdk_in_gemfile
185+
class pdk_in_gemfile {}
186+
EOS
184187
end
185188
end
186189

@@ -190,7 +193,7 @@ class foo {
190193

191194
describe command('pdk validate puppet --format text:stdout --format junit:report.xml') do
192195
its(:exit_status) { is_expected.to eq(0) }
193-
its(:stdout) { is_expected.to match(/\(warning\):.*class not documented.*\(#{Regexp.escape(init_pp)}.+\)/i) }
196+
its(:stdout) { is_expected.to match(/\(warning\):.*indent should be 0 chars and is 2.*\(#{Regexp.escape(init_pp)}.+\)/i) }
194197
its(:stderr) { is_expected.not_to match(epp_spinner_text) }
195198
its(:stderr) { is_expected.to match(syntax_spinner_text) }
196199
its(:stderr) { is_expected.to match(lint_spinner_text) }

0 commit comments

Comments
 (0)