Mercurial > repos > other > Puppet
annotate modules/stdlib/spec/functions/deprecation_spec.rb @ 320:99e3ca448d55
Fix Remi PHP on CentOS 8
It uses the new "modules" approach, so we need to use a new
package provider
They also use different signing keys
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 01 Mar 2020 10:58:00 +0000 |
parents | d9352a684e62 |
children |
rev | line source |
---|---|
272 | 1 require 'spec_helper' |
2 | |
3 if Puppet::Util::Package.versioncmp(Puppet.version, '4.5.0') >= 0 | |
4 describe 'deprecation' do | |
5 before(:each) do | |
6 # this is to reset the strict variable to default | |
7 Puppet.settings[:strict] = :warning | |
8 end | |
9 | |
10 it { is_expected.not_to eq(nil) } | |
11 it { is_expected.to run.with_params.and_raise_error(ArgumentError) } | |
12 | |
13 it 'displays a single warning' do | |
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
272
diff
changeset
|
14 if Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') >= 0 && Puppet::Util::Package.versioncmp(Puppet.version, '5.5.7') < 0 |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
272
diff
changeset
|
15 expect(Puppet).to receive(:deprecation_warning).with('heelo at :', 'key') |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
272
diff
changeset
|
16 expect(Puppet).to receive(:deprecation_warning).with("Modifying 'autosign' as a setting is deprecated.") |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
272
diff
changeset
|
17 else |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
272
diff
changeset
|
18 expect(Puppet).to receive(:warning).with(include('heelo')).once |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
272
diff
changeset
|
19 end |
272 | 20 is_expected.to run.with_params('key', 'heelo') |
21 end | |
22 | |
23 it 'displays a single warning, despite multiple calls' do | |
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
272
diff
changeset
|
24 if Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') >= 0 && Puppet::Util::Package.versioncmp(Puppet.version, '5.5.7') < 0 |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
272
diff
changeset
|
25 expect(Puppet).to receive(:deprecation_warning).with('heelo at :', 'key').twice |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
272
diff
changeset
|
26 expect(Puppet).to receive(:deprecation_warning).with("Modifying 'autosign' as a setting is deprecated.") |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
272
diff
changeset
|
27 else |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
272
diff
changeset
|
28 expect(Puppet).to receive(:warning).with(include('heelo')).once |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
272
diff
changeset
|
29 end |
272 | 30 (0..1).each do |_i| |
31 is_expected.to run.with_params('key', 'heelo') | |
32 end | |
33 end | |
34 | |
35 it 'fails twice with message, with multiple calls. when strict= :error' do | |
36 Puppet.settings[:strict] = :error | |
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
272
diff
changeset
|
37 expect(Puppet).to receive(:warning).with(include('heelo')).never |
272 | 38 (0..1).each do |_i| |
39 is_expected.to run.with_params('key', 'heelo').and_raise_error(RuntimeError, %r{deprecation. key. heelo}) | |
40 end | |
41 end | |
42 | |
43 it 'displays nothing, despite multiple calls. strict= :off' do | |
44 Puppet.settings[:strict] = :off | |
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
272
diff
changeset
|
45 expect(Puppet).to receive(:warning).with(include('heelo')).never |
272 | 46 (0..1).each do |_i| |
47 is_expected.to run.with_params('key', 'heelo') | |
48 end | |
49 end | |
50 | |
51 after(:each) do | |
52 # this is to reset the strict variable to default | |
53 Puppet.settings[:strict] = :warning | |
54 end | |
55 end | |
56 elsif Puppet.version.to_f < 4.0 | |
57 # Puppet version < 4 will use these tests. | |
58 describe 'deprecation' do | |
59 after(:each) do | |
60 ENV.delete('STDLIB_LOG_DEPRECATIONS') | |
61 end | |
62 before(:each) do | |
63 ENV['STDLIB_LOG_DEPRECATIONS'] = 'true' | |
64 end | |
65 it { is_expected.not_to eq(nil) } | |
66 it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } | |
67 | |
68 it 'displays a single warning' do | |
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
272
diff
changeset
|
69 expect(scope).to receive(:warning).with(include('heelo')) |
272 | 70 is_expected.to run.with_params('key', 'heelo') |
71 end | |
72 end | |
73 end |