1 | #! /usr/bin/env ruby -S rspec
|
---|
2 | require 'spec_helper_acceptance'
|
---|
3 |
|
---|
4 | describe 'deprecation function' do
|
---|
5 |
|
---|
6 | if fact('operatingsystem') == 'windows'
|
---|
7 | test_file = 'C:/deprecation'
|
---|
8 | else
|
---|
9 | test_file = "/tmp/deprecation"
|
---|
10 | end
|
---|
11 |
|
---|
12 | # It seems that Windows needs everything to be on one line when using puppet apply -e, otherwise the manifests would be in an easier format
|
---|
13 | add_file_manifest = "\"deprecation('key', 'message') file { '#{test_file}': ensure => present, content => 'test', }\""
|
---|
14 | remove_file_manifest = "file { '#{test_file}': ensure => absent }"
|
---|
15 |
|
---|
16 | before :all do
|
---|
17 | apply_manifest(remove_file_manifest)
|
---|
18 | end
|
---|
19 |
|
---|
20 | context 'with --strict=error', if: get_puppet_version =~ /^4/ do
|
---|
21 | before :all do
|
---|
22 | @result = on(default, puppet('apply', '--strict=error', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
|
---|
23 | end
|
---|
24 |
|
---|
25 | after :all do
|
---|
26 | apply_manifest(remove_file_manifest)
|
---|
27 | end
|
---|
28 |
|
---|
29 | it "should return an error" do
|
---|
30 | expect(@result.exit_code).to eq(1)
|
---|
31 | end
|
---|
32 |
|
---|
33 | it "should show the error message" do
|
---|
34 | expect(@result.stderr).to match(/deprecation. key. message/)
|
---|
35 | end
|
---|
36 |
|
---|
37 | describe file("#{test_file}") do
|
---|
38 | it { is_expected.not_to be_file }
|
---|
39 | end
|
---|
40 | end
|
---|
41 |
|
---|
42 | context 'with --strict=warning', if: get_puppet_version =~ /^4/ do
|
---|
43 | before :all do
|
---|
44 | @result = on(default, puppet('apply', '--strict=warning', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
|
---|
45 | end
|
---|
46 |
|
---|
47 | after :all do
|
---|
48 | apply_manifest(remove_file_manifest)
|
---|
49 | end
|
---|
50 |
|
---|
51 | it "should not return an error" do
|
---|
52 | expect(@result.exit_code).to eq(0)
|
---|
53 | end
|
---|
54 |
|
---|
55 | it "should show the error message" do
|
---|
56 | expect(@result.stderr).to match(/Warning: message/)
|
---|
57 | end
|
---|
58 |
|
---|
59 | describe file("#{test_file}") do
|
---|
60 | it { is_expected.to be_file }
|
---|
61 | end
|
---|
62 | end
|
---|
63 |
|
---|
64 | context 'with --strict=off', if: get_puppet_version =~ /^4/ do
|
---|
65 | before :all do
|
---|
66 | @result = on(default, puppet('apply', '--strict=off', '-e', add_file_manifest), acceptable_exit_codes: (0...256))
|
---|
67 | end
|
---|
68 |
|
---|
69 | after :all do
|
---|
70 | apply_manifest(remove_file_manifest)
|
---|
71 | end
|
---|
72 |
|
---|
73 | it "should not return an error" do
|
---|
74 | expect(@result.exit_code).to eq(0)
|
---|
75 | end
|
---|
76 |
|
---|
77 | it "should not show the error message" do
|
---|
78 | expect(@result.stderr).not_to match(/Warning: message/)
|
---|
79 | end
|
---|
80 |
|
---|
81 | describe file("#{test_file}") do
|
---|
82 | it { is_expected.to be_file }
|
---|
83 | end
|
---|
84 | end
|
---|
85 | end
|
---|