|
1 | 1 | require 'spec_helper' |
2 | 2 |
|
3 | 3 | if Puppet.version.to_f >= 4.0 |
| 4 | + # validate_legacy requires a proper scope to run, so we have to trigger a true compilation here, |
| 5 | + # instead of being able to leverage the function test group. |
4 | 6 | describe 'test::validate_legacy', type: :class do |
5 | | - |
| 7 | + |
6 | 8 | describe 'validate_legacy passes assertion of type but not previous validation' do |
7 | | - let(:params) {{ type: "Optional[Integer]", prev_validation: "validate_re", value: 5, previous_args1: ["^\\d+$", ""] }} |
| 9 | + let(:params) {{ type: "Optional[Integer]", prev_validation: "validate_re", value: 5, previous_arg1: ["^\\d+$", ""] }} |
8 | 10 | it { Puppet.expects(:warn).with(includes('Accepting previously invalid value for target_type')) |
9 | 11 | is_expected.to compile } |
10 | 12 | end |
11 | 13 |
|
12 | 14 | describe 'validate_legacy passes assertion of type and previous validation' do |
13 | | - let(:params) {{ type: "Optional[String]", prev_validation: "validate_re", value: "5", previous_args1: ["."] }} |
| 15 | + let(:params) {{ type: "Optional[String]", prev_validation: "validate_re", value: "5", previous_arg1: ["."] }} |
14 | 16 | it { is_expected.to compile } |
15 | 17 | end |
16 | 18 |
|
17 | 19 | describe 'validate_legacy fails assertion of type and passes previous validation' do |
18 | | - let(:params) {{ type: "Optional[Integer]", prev_validation: "validate_re", value: "5", previous_args1: ["."] }} |
19 | | - it { Puppet.expects(:warn).with(includes('expected')) |
20 | | - is_expected.to compile } |
| 20 | + let(:params) {{ type: "Optional[Integer]", prev_validation: "validate_re", value: "5", previous_arg1: ["."] }} |
| 21 | + it { |
| 22 | + Puppet.expects(:warn).with(includes('expected')) |
| 23 | + is_expected.to compile |
| 24 | + } |
21 | 25 | end |
22 | 26 |
|
23 | 27 | describe 'validate_legacy fails assertion and fails previous validation' do |
24 | | - let(:params) {{ type: "Optional[Integer]", prev_validation: "validate_re", value: "5", previous_args1: ["thisisnotright"] }} |
| 28 | + let(:params) {{ type: "Optional[Integer]", prev_validation: "validate_re", value: "5", previous_arg1: ["thisisnotright"] }} |
25 | 29 | it { is_expected.to compile.and_raise_error(/Error while evaluating a Function Call, \w* expected an \w* value, got \w*/) } |
26 | 30 | end |
27 | 31 |
|
| 32 | + describe 'validate_legacy works with multi-argument validate_ functions' do |
| 33 | + let(:params) {{ type: "Integer", prev_validation: "validate_integer", value: 10, previous_arg1: 0, previous_arg2: 100 }} |
| 34 | + it { is_expected.to compile } |
| 35 | + end |
28 | 36 | end |
29 | 37 | end |
0 commit comments